File tree 4 files changed +11
-10
lines changed
Sources/ArgumentParser/Completions
Tests/ArgumentParserUnitTests/Snapshots
4 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -149,12 +149,13 @@ extension ArgumentDefinition {
149
149
/// Returns a string with the arguments for the callback to generate custom completions for
150
150
/// this argument.
151
151
func customCompletionCall( _ commands: [ ParsableCommand . Type ] ) -> String {
152
- let subcommandNames = commands . dropFirst ( ) . map { $0 . _commandName } . joined (
153
- separator : " " )
152
+ let subcommandNames =
153
+ commands . dropFirst ( ) . map { " \( $0 . _commandName ) " } . joined ( )
154
154
let argumentName =
155
155
names. preferredName? . synopsisString
156
- ?? self . help. keys. first? . fullPathString ?? " --- "
157
- return " ---completion \( subcommandNames) -- \( argumentName) "
156
+ ?? self . help. keys. first? . fullPathString
157
+ ?? " --- "
158
+ return " ---completion \( subcommandNames) -- \( argumentName) "
158
159
}
159
160
}
160
161
Original file line number Diff line number Diff line change @@ -182,11 +182,11 @@ _base_test() {
182
182
# Offer positional completions
183
183
case " ${positional_number} " in
184
184
1)
185
- __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- argument) "
185
+ __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- argument) "
186
186
return
187
187
;;
188
188
2)
189
- __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- nested.nestedArgument) "
189
+ __base_test_add_completions -W " $( __base_test_custom_complete ---completion -- nested.nestedArgument) "
190
190
return
191
191
;;
192
192
esac
Original file line number Diff line number Diff line change @@ -80,8 +80,8 @@ complete -c 'base-test' -n '__base-test_should_offer_completions_for "base-test"
80
80
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test"' -l kind-counter
81
81
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test"' -l rep1 -rfka ' '
82
82
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test"' -s r -l rep2 -rfka ' '
83
- complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 1' -fka ' (__base-test_custom_completion ---completion -- argument)'
84
- complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 2' -fka ' (__base-test_custom_completion ---completion -- nested.nestedArgument)'
83
+ complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 1' -fka ' (__base-test_custom_completion ---completion -- argument)'
84
+ complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 2' -fka ' (__base-test_custom_completion ---completion -- nested.nestedArgument)'
85
85
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test"' -s h -l help -d ' Show help information.'
86
86
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 3' -fa ' sub-command' -d ' '
87
87
complete -c ' base-test' -n ' __base-test_should_offer_completions_for "base-test" 3' -fa ' escaped-command' -d ' '
Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ _base-test() {
47
47
' *--kind-counter'
48
48
' *--rep1:rep1:'
49
49
' *' {-r,--rep2}' :rep2:'
50
- ' :argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}'
51
- ' :nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}'
50
+ ' :argument:{__base-test_custom_complete "${command_name}" ---completion -- argument "${command_line[@]}"}'
51
+ ' :nested-argument:{__base-test_custom_complete "${command_name}" ---completion -- nested.nestedArgument "${command_line[@]}"}'
52
52
' (-h --help)' {-h,--help}' [Show help information.]'
53
53
' (-): :->command'
54
54
' (-)*:: :->arg'
You can’t perform that action at this time.
0 commit comments