|
|
@ -76,6 +76,8 @@ pub enum Command { |
|
|
|
},
|
|
|
|
/// List all available templates that can be downloaded
|
|
|
|
ListTemplates,
|
|
|
|
/// Write a completion definition for the specified shell to stdout (bash, zsh, etc.)
|
|
|
|
DumpCompletions { shell: Option<structopt::clap::Shell> },
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Runs the command `add`
|
|
|
@ -134,12 +136,26 @@ fn run_list_templates() -> Result<()> { |
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Runs the command `dump-completion` to generate a shell completion script
|
|
|
|
fn run_dump_completion(shell: Option<structopt::clap::Shell>) -> Result<()> {
|
|
|
|
let shell = shell.ok_or(ErrorKind::NoShellProvided)?;
|
|
|
|
debug!("Request to dump completion for {}", shell);
|
|
|
|
CliOpts::clap().gen_completions_to(
|
|
|
|
CliOpts::clap().get_bin_name().unwrap_or_else(|| structopt::clap::crate_name!()),
|
|
|
|
shell,
|
|
|
|
&mut ::std::io::stdout(),
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The actual `main()`
|
|
|
|
pub fn main(opts: CliOpts) -> Result<()> {
|
|
|
|
match opts.cmd {
|
|
|
|
Command::Add { glob } => run_add(&glob)?,
|
|
|
|
Command::Get { lang } => run_get(&lang)?,
|
|
|
|
Command::ListTemplates => run_list_templates()?,
|
|
|
|
Command::DumpCompletions { shell } => run_dump_completion(shell)?,
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|