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