File tree 5 files changed +18
-15
lines changed
5 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -136,11 +136,14 @@ fn gen_fish_inner(
136
136
buffer. push ( '\n' ) ;
137
137
}
138
138
139
+ let has_positionals = cmd. get_positionals ( ) . next ( ) . is_some ( ) ;
140
+ if !has_positionals {
141
+ basic_template. push_str ( " -f" ) ;
142
+ }
139
143
for subcommand in cmd. get_subcommands ( ) {
140
144
for subcommand_name in subcommand. get_name_and_visible_aliases ( ) {
141
145
let mut template = basic_template. clone ( ) ;
142
146
143
- template. push_str ( " -f" ) ;
144
147
template. push_str ( format ! ( " -a \" {}\" " , subcommand_name) . as_str ( ) ) ;
145
148
146
149
if let Some ( data) = subcommand. get_about ( ) {
Original file line number Diff line number Diff line change 1
1
complete -c my-app -n " __fish_use_subcommand" -s c -s C -l config -l conf -d ' some config file'
2
2
complete -c my-app -n " __fish_use_subcommand" -s h -l help -d ' Print help'
3
3
complete -c my-app -n " __fish_use_subcommand" -s V -l version -d ' Print version'
4
- complete -c my-app -n " __fish_use_subcommand" -f - a " test" -d ' tests things'
5
- complete -c my-app -n " __fish_use_subcommand" -f - a " help" -d ' Print this message or the help of the given subcommand(s)'
4
+ complete -c my-app -n " __fish_use_subcommand" -a " test" -d ' tests things'
5
+ complete -c my-app -n " __fish_use_subcommand" -a " help" -d ' Print this message or the help of the given subcommand(s)'
6
6
complete -c my-app -n " __fish_seen_subcommand_from test" -l case -d ' the case to test' -r
7
7
complete -c my-app -n " __fish_seen_subcommand_from test" -s h -l help -d ' Print help'
8
8
complete -c my-app -n " __fish_seen_subcommand_from test" -s V -l version -d ' Print version'
Original file line number Diff line number Diff line change 1
1
complete -c my-app -n " __fish_use_subcommand" -s c -s C -l config -l conf -d ' some config file'
2
2
complete -c my-app -n " __fish_use_subcommand" -s h -l help -d ' Print help'
3
3
complete -c my-app -n " __fish_use_subcommand" -s V -l version -d ' Print version'
4
- complete -c my-app -n " __fish_use_subcommand" -f - a " test" -d ' tests things'
5
- complete -c my-app -n " __fish_use_subcommand" -f - a " some_cmd" -d ' tests other things'
6
- complete -c my-app -n " __fish_use_subcommand" -f - a " some-cmd-with-hyphens"
7
- complete -c my-app -n " __fish_use_subcommand" -f - a " some-hidden-cmd"
8
- complete -c my-app -n " __fish_use_subcommand" -f - a " help" -d ' Print this message or the help of the given subcommand(s)'
4
+ complete -c my-app -n " __fish_use_subcommand" -a " test" -d ' tests things'
5
+ complete -c my-app -n " __fish_use_subcommand" -a " some_cmd" -d ' tests other things'
6
+ complete -c my-app -n " __fish_use_subcommand" -a " some-cmd-with-hyphens"
7
+ complete -c my-app -n " __fish_use_subcommand" -a " some-hidden-cmd"
8
+ complete -c my-app -n " __fish_use_subcommand" -a " help" -d ' Print this message or the help of the given subcommand(s)'
9
9
complete -c my-app -n " __fish_seen_subcommand_from test" -l case -d ' the case to test' -r
10
10
complete -c my-app -n " __fish_seen_subcommand_from test" -s h -l help -d ' Print help'
11
11
complete -c my-app -n " __fish_seen_subcommand_from test" -s V -l version -d ' Print version'
Original file line number Diff line number Diff line change 1
1
complete -c my-app -n " __fish_use_subcommand" -s c -s C -l config -l conf -d ' some config file'
2
2
complete -c my-app -n " __fish_use_subcommand" -s h -l help -d ' Print help'
3
3
complete -c my-app -n " __fish_use_subcommand" -s V -l version -d ' Print version'
4
- complete -c my-app -n " __fish_use_subcommand" -f - a " test" -d ' tests things'
5
- complete -c my-app -n " __fish_use_subcommand" -f - a " some_cmd" -d ' top level subcommand'
6
- complete -c my-app -n " __fish_use_subcommand" -f - a " some_cmd_alias" -d ' top level subcommand'
7
- complete -c my-app -n " __fish_use_subcommand" -f - a " help" -d ' Print this message or the help of the given subcommand(s)'
4
+ complete -c my-app -n " __fish_use_subcommand" -a " test" -d ' tests things'
5
+ complete -c my-app -n " __fish_use_subcommand" -a " some_cmd" -d ' top level subcommand'
6
+ complete -c my-app -n " __fish_use_subcommand" -a " some_cmd_alias" -d ' top level subcommand'
7
+ complete -c my-app -n " __fish_use_subcommand" -a " help" -d ' Print this message or the help of the given subcommand(s)'
8
8
complete -c my-app -n " __fish_seen_subcommand_from test" -l case -d ' the case to test' -r
9
9
complete -c my-app -n " __fish_seen_subcommand_from test" -s h -l help -d ' Print help'
10
10
complete -c my-app -n " __fish_seen_subcommand_from test" -s V -l version -d ' Print version'
Original file line number Diff line number Diff line change 1
1
complete -c my-app -n " __fish_use_subcommand" -s h -l help -d ' Print help'
2
- complete -c my-app -n " __fish_use_subcommand" -f - a " foo"
3
- complete -c my-app -n " __fish_use_subcommand" -f - a " bar"
4
- complete -c my-app -n " __fish_use_subcommand" -f - a " help" -d ' Print this message or the help of the given subcommand(s)'
2
+ complete -c my-app -n " __fish_use_subcommand" -a " foo"
3
+ complete -c my-app -n " __fish_use_subcommand" -a " bar"
4
+ complete -c my-app -n " __fish_use_subcommand" -a " help" -d ' Print this message or the help of the given subcommand(s)'
5
5
complete -c my-app -n " __fish_seen_subcommand_from foo" -s h -l help -d ' Print help'
6
6
complete -c my-app -n " __fish_seen_subcommand_from bar" -s h -l help -d ' Print help'
7
7
complete -c my-app -n " __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from foo bar help" -f -a " foo"
You can’t perform that action at this time.
0 commit comments