mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-05-24 08:17:14 +02:00
improvements
This commit is contained in:
parent
114e567826
commit
3a8ebca75e
4 changed files with 59 additions and 56 deletions
32
build.rs
32
build.rs
|
@ -3,26 +3,38 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{path::PathBuf, io::Error};
|
||||
use std::{
|
||||
fs,
|
||||
io::{self, Error},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use clap_complete::{generate_to, shells, Generator};
|
||||
|
||||
include!("src/cli.rs");
|
||||
|
||||
const OUTDIR: &str = "completions";
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let outdir = "completions";
|
||||
let mut cmd = build_cli();
|
||||
|
||||
let path = generate_completions(shells::Bash, &mut cmd, outdir)?;
|
||||
println!("cargo:debug=completion file is generated: {:?}", path);
|
||||
let path = generate_completions(shells::Zsh, &mut cmd, outdir)?;
|
||||
println!("cargo:debug=completion file is generated: {:?}", path);
|
||||
let path = generate_completions(shells::Fish, &mut cmd, outdir)?;
|
||||
println!("cargo:debug=completion file is generated: {:?}", path);
|
||||
if let Err(why) = fs::create_dir(OUTDIR) {
|
||||
if why.kind() != io::ErrorKind::AlreadyExists {
|
||||
eprintln!("cargo:error=could not create directory: {OUTDIR}");
|
||||
return Err(why);
|
||||
}
|
||||
}
|
||||
|
||||
let path = generate_completions(shells::Bash, &mut cmd)?;
|
||||
println!("cargo:debug=completion file is generated: {path:?}");
|
||||
let path = generate_completions(shells::Zsh, &mut cmd)?;
|
||||
println!("cargo:debug=completion file is generated: {path:?}");
|
||||
let path = generate_completions(shells::Fish, &mut cmd)?;
|
||||
println!("cargo:debug=completion file is generated: {path:?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_completions<G: Generator>(shell: G, cmd: &mut clap::Command, outdir: &str) -> Result<PathBuf, Error> {
|
||||
generate_to(shell, cmd, "lamp", outdir)
|
||||
fn generate_completions<G: Generator>(shell: G, cmd: &mut clap::Command) -> Result<PathBuf, Error> {
|
||||
generate_to(shell, cmd, env!("CARGO_PKG_NAME"), OUTDIR)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue