From d4d8caf98bd3595f182d014e4606bbb79dafee05 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 10 Feb 2021 11:00:48 -0800 Subject: shell completions (via hidden flag) --- fatcat-cli/src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'fatcat-cli/src') 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(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::() { -- cgit v1.2.3