diff --git a/clap_generate/src/generators/shells/bash.rs b/clap_generate/src/generators/shells/bash.rs index 11075726..e975e43a 100644 --- a/clap_generate/src/generators/shells/bash.rs +++ b/clap_generate/src/generators/shells/bash.rs @@ -201,9 +201,20 @@ fn all_options_for_path(app: &App, path: &str) -> String { longs = utils::longs_and_visible_aliases(p) .iter() .fold(String::new(), |acc, l| format!("{} --{}", acc, l)), - pos = p - .get_positionals() - .fold(String::new(), |acc, p| format!("{} {}", acc, p)), + pos = p.get_positionals().fold(String::new(), |acc, p| { + if let Some(vals) = p.get_possible_values() { + format!( + "{} {}", + acc, + vals.iter() + .map(|x| x.get_name()) + .collect::>() + .join(" ") + ) + } else { + format!("{} {}", acc, p) + } + }), subcmds = scs.join(" "), ); diff --git a/clap_generate/tests/completions/bash.rs b/clap_generate/tests/completions/bash.rs index 5a1773b1..99966edf 100644 --- a/clap_generate/tests/completions/bash.rs +++ b/clap_generate/tests/completions/bash.rs @@ -14,6 +14,7 @@ fn build_app_with_name(s: &'static str) -> App<'static> { .value_hint(ValueHint::FilePath) .about("some input file"), ) + .arg(Arg::new("choice").possible_values(["first", "second"])) .subcommand( App::new("test").about("tests things").arg( Arg::new("case") @@ -57,7 +58,7 @@ static BASH: &str = r#"_myapp() { case "${cmd}" in myapp) - opts=" -h -V --help --version test help" + opts=" -h -V --help --version first second test help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -160,7 +161,7 @@ static BASH_SPECIAL_CMDS: &str = r#"_my_app() { case "${cmd}" in my_app) - opts=" -h -V --help --version test some_cmd some-cmd-with-hypens help" + opts=" -h -V --help --version first second test some_cmd some-cmd-with-hypens help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0