generate all completions by default
This commit is contained in:
parent
06f97592c1
commit
d8aca91136
15
src/cli.rs
15
src/cli.rs
@ -632,12 +632,25 @@ pub fn run_cli() -> Fido2LuksResult<()> {
|
||||
}
|
||||
},
|
||||
Command::GenerateCompletions { shell, out_dir } => {
|
||||
// zsh won't work atm https://github.com/clap-rs/clap/issues/1822
|
||||
if let Some(s) = shell {
|
||||
if s.as_str() == "zsh" {
|
||||
unimplemented!("zsh completions are broken atm: see https://github.com/clap-rs/clap/issues/1822")
|
||||
}
|
||||
}
|
||||
for variant in Shell::variants().iter().filter(|v| *v != &"zsh") {
|
||||
if let Some(s) = shell {
|
||||
if *variant != s.as_str() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Args::clap().gen_completions(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
Shell::from_str(shell.as_str())
|
||||
Shell::from_str(variant)
|
||||
.expect("structopt shouldn't allow us to reach this point"),
|
||||
&out_dir,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -259,11 +259,12 @@ pub enum Command {
|
||||
Connected,
|
||||
Token(TokenCommand),
|
||||
/// Generate bash completion scripts
|
||||
/// Example: fido2luks completions --shell bash /usr/share/bash-completion/completions
|
||||
#[structopt(name = "completions", setting = AppSettings::Hidden)]
|
||||
GenerateCompletions {
|
||||
/// Shell to generate completions for
|
||||
#[structopt(possible_values = &Shell::variants()[..])]
|
||||
shell: String,
|
||||
#[structopt(short = "s", long = "shell",possible_values = &Shell::variants()[..])]
|
||||
shell: Option<String>,
|
||||
out_dir: PathBuf,
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user