mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
fix(fish): Don't ignore files if has positional args
This commit is contained in:
parent
3a2fb25947
commit
5ee1a2570e
5 changed files with 18 additions and 15 deletions
|
@ -136,11 +136,14 @@ fn gen_fish_inner(
|
|||
buffer.push('\n');
|
||||
}
|
||||
|
||||
let has_positionals = cmd.get_positionals().next().is_some();
|
||||
if !has_positionals {
|
||||
basic_template.push_str(" -f");
|
||||
}
|
||||
for subcommand in cmd.get_subcommands() {
|
||||
for subcommand_name in subcommand.get_name_and_visible_aliases() {
|
||||
let mut template = basic_template.clone();
|
||||
|
||||
template.push_str(" -f");
|
||||
template.push_str(format!(" -a \"{}\"", subcommand_name).as_str());
|
||||
|
||||
if let Some(data) = subcommand.get_about() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
complete -c my-app -n "__fish_use_subcommand" -s c -s C -l config -l conf -d 'some config file'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s V -l version -d 'Print version'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -l case -d 'the case to test' -r
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s V -l version -d 'Print version'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
complete -c my-app -n "__fish_use_subcommand" -s c -s C -l config -l conf -d 'some config file'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s V -l version -d 'Print version'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "some_cmd" -d 'tests other things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "some-cmd-with-hyphens"
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "some-hidden-cmd"
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "some_cmd" -d 'tests other things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "some-cmd-with-hyphens"
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "some-hidden-cmd"
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -l case -d 'the case to test' -r
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s V -l version -d 'Print version'
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
complete -c my-app -n "__fish_use_subcommand" -s c -s C -l config -l conf -d 'some config file'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_use_subcommand" -s V -l version -d 'Print version'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "some_cmd" -d 'top level subcommand'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "some_cmd_alias" -d 'top level subcommand'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "test" -d 'tests things'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "some_cmd" -d 'top level subcommand'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "some_cmd_alias" -d 'top level subcommand'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -l case -d 'the case to test' -r
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from test" -s V -l version -d 'Print version'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
complete -c my-app -n "__fish_use_subcommand" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "foo"
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "bar"
|
||||
complete -c my-app -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "foo"
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "bar"
|
||||
complete -c my-app -n "__fish_use_subcommand" -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from foo" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from bar" -s h -l help -d 'Print help'
|
||||
complete -c my-app -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from foo bar help" -f -a "foo"
|
||||
|
|
Loading…
Add table
Reference in a new issue