diff options
author | Bryan Newbold <bnewbold@archive.org> | 2021-02-10 11:00:48 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2021-02-10 11:00:48 -0800 |
commit | d4d8caf98bd3595f182d014e4606bbb79dafee05 (patch) | |
tree | b464947500471413aba22d7415cf2b32912ae46a | |
parent | efdc17248cbf8336f28c377a301752604fb6db74 (diff) | |
download | fatcat-cli-d4d8caf98bd3595f182d014e4606bbb79dafee05.tar.gz fatcat-cli-d4d8caf98bd3595f182d014e4606bbb79dafee05.zip |
shell completions (via hidden flag)
-rw-r--r-- | fatcat-cli/Cargo.toml | 2 | ||||
-rw-r--r-- | fatcat-cli/src/main.rs | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/fatcat-cli/Cargo.toml b/fatcat-cli/Cargo.toml index f7885b6..ac65298 100644 --- a/fatcat-cli/Cargo.toml +++ b/fatcat-cli/Cargo.toml @@ -54,4 +54,6 @@ description will go here. assets = [ ["target/release/fatcat-cli", "usr/bin/", "755"], ["../extra/fatcat-cli.1", "usr/share/man/man1/", "644"], + ["../extra/fatcat-cli.bash_completions", "usr/share/bash-completion/completions/fatcat-cli", "644"], + ["../extra/fatcat-cli.zsh_completions", "usr/share/zsh/vendor-completions/_fatcat-cli", "644"], ] diff --git a/fatcat-cli/src/main.rs b/fatcat-cli/src/main.rs index 3b4a81b..6e3f2c7 100644 --- a/fatcat-cli/src/main.rs +++ b/fatcat-cli/src/main.rs @@ -44,6 +44,12 @@ struct Opt { #[structopt(global = true, long, short = "v", parse(from_occurrences))] verbose: i8, + #[structopt(long = "--shell-completions", hidden = true)] + shell_completions: Option<structopt::clap::Shell>, + + #[structopt(long = "--meow", hidden = true)] + meow: bool, + #[structopt(subcommand)] cmd: Command, } @@ -288,6 +294,15 @@ fn main() -> Result<()> { #[cfg(windows)] colored_json::enable_ansi_support(); + if let Some(shell) = opt.shell_completions { + Opt::clap().gen_completions_to("fatcat-cli", shell, &mut std::io::stdout()); + std::process::exit(0); + } + if opt.meow { + println!("meow meow"); + std::process::exit(0); + } + if let Err(err) = run(opt) { // Be graceful about some errors if let Some(io_err) = err.root_cause().downcast_ref::<std::io::Error>() { |