Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ extension CommandInfoV0 {
String?.none
}
case .list(let list):
"-\(r)fka '\(list.joined(separator: separator))'"
"""
-\(r)fka '\(
list
.map { "\\'\($0.fishEscapeForSingleQuotedString(iterationCount: 2))\\'" }
.joined(separator: separator)
)'
"""
case .file(let extensions):
switch extensions.count {
case 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "mat
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats" -eq 1' -fa 'average' -d 'Print the average of the values.'
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats" -eq 1' -fa 'stdev' -d 'Print the standard deviation of the values.'
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats" -eq 1' -fa 'quantiles' -d 'Print the quantiles of the values (TBD).'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats average" kind' -l 'kind' -d 'The kind of average to provide.' -rfka 'mean median mode'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats average" kind' -l 'kind' -d 'The kind of average to provide.' -rfka '\'mean\' \'median\' \'mode\''
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats average" version' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats average" h help' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats stdev" version' -l 'version' -d 'Show the version.'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats stdev" h help' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats quantiles" -eq 1' -fka 'alphabet alligator branch braggart'
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats quantiles" -eq 1' -fka '\'alphabet\' \'alligator\' \'branch\' \'braggart\''
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats quantiles" -eq 2' -fka '(__math_custom_completion ---completion stats quantiles -- positional@1 (count (__math_tokens -pc)) (__math_tokens -tC))'
complete -c 'math' -n '__math_should_offer_completions_for_positional "math stats quantiles" -eq 3' -fka '(__math_custom_completion ---completion stats quantiles -- positional@2)'
complete -c 'math' -n '__math_should_offer_completions_for_flags_or_options "math stats quantiles" file' -l 'file' -rfa '(set -l exts \'txt\' \'md\';for p in (string match -e -- \'*/\' (commandline -t);or printf \n)*.{$exts};printf %s\n $p;end;__fish_complete_directories (commandline -t) \'\')'
Expand Down
3 changes: 3 additions & 0 deletions Tests/ArgumentParserUnitTests/CompletionScriptTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ extension SerializedTests.CompletionScriptTests {

@Argument(completion: .custom { _, _, _ in candidates(prefix: "i") })
var two: String

@Option(completion: .list([#"'"#, #"\"#, "a b"]))
var three: String
}
}

Expand Down
6 changes: 5 additions & 1 deletion Tests/ArgumentParserUnitTests/Snapshots/base_Bash().bash
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,18 @@ _base-test_escaped-command() {
repeating_flags=()
non_repeating_flags=(-h --help)
repeating_options=()
non_repeating_options=(--o:n[e)
non_repeating_options=(--o:n[e --three)
__base-test_offer_flags_options 1

# Offer option value completions
case "${prev}" in
'--o:n[e')
return
;;
'--three')
__base-test_add_completions -W ''\'''$'\n''\'$'\n''a b'
return
;;
esac

# Offer positional completions
Expand Down
9 changes: 5 additions & 4 deletions Tests/ArgumentParserUnitTests/Snapshots/base_Fish().fish
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function __base-test_parse_tokens -S
case 'sub-command'
__base-test_parse_subcommand 0 'h/help'
case 'escaped-command'
__base-test_parse_subcommand 1 'o:n[e=' 'h/help'
__base-test_parse_subcommand 1 'o:n[e=' 'three=' 'h/help'
case 'help'
__base-test_parse_subcommand -r 1
end
Expand Down Expand Up @@ -82,11 +82,11 @@ end

complete -c 'base-test' -f
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" name' -l 'name' -d 'The user\'s name.' -rfka ''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" kind' -l 'kind' -rfka 'one two custom-three'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" other-kind' -l 'other-kind' -rfka 'b1_fish b2_fish b3_fish'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" kind' -l 'kind' -rfka '\'one\' \'two\' \'custom-three\''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" other-kind' -l 'other-kind' -rfka '\'b1_fish\' \'b2_fish\' \'b3_fish\''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" path1' -l 'path1' -rF
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" path2' -l 'path2' -rF
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" path3' -l 'path3' -rfka 'c1_fish c2_fish c3_fish'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" path3' -l 'path3' -rfka '\'c1_fish\' \'c2_fish\' \'c3_fish\''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" one' -l 'one'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" two' -l 'two'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test" custom-three' -l 'custom-three'
Expand All @@ -102,4 +102,5 @@ complete -c 'base-test' -n '__base-test_should_offer_completions_for_positional
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test sub-command" h help' -s 'h' -l 'help' -d 'Show help information.'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test escaped-command" o:n[e' -l 'o:n[e' -d 'Escaped chars: \'[]\\.' -rfka ''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_positional "base-test escaped-command" -eq 1' -fka '(__base-test_custom_completion ---completion escaped-command -- positional@0 (count (__base-test_tokens -pc)) (__base-test_tokens -tC))'
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test escaped-command" three' -l 'three' -rfka '\'\\\'\' \'\\\\\' \'a b\''
complete -c 'base-test' -n '__base-test_should_offer_completions_for_flags_or_options "base-test escaped-command" h help' -s 'h' -l 'help' -d 'Show help information.'
2 changes: 2 additions & 0 deletions Tests/ArgumentParserUnitTests/Snapshots/base_Zsh().zsh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ _base-test_sub-command() {

_base-test_escaped-command() {
local -i ret=1
local -ar ___three=(''\''' '\' 'a b')
local -ar arg_specs=(
'--o\:n\[e[Escaped chars\: '\''\[\]\\.]:path\[\:options\]:'
':two:{__base-test_custom_complete ---completion escaped-command -- positional@0 "${current_word_index}" "$(__base-test_cursor_index_in_current_word)"}'
'--three:three:{__base-test_complete "${___three[@]}"}'
'(-h --help)'{-h,--help}'[Show help information.]'
)
_arguments -w -s -S : "${arg_specs[@]}" && ret=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ complete -c 'defaultasflag-test' -f
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" bin-path' -l 'bin-path' -rfa '(__defaultasflag-test_complete_directories)'
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" count' -l 'count' -rfka ''
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" verbose' -l 'verbose' -rfka ''
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" log-level' -l 'log-level' -rfka 'DEBUG INFO WARN ERROR'
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" log-level' -l 'log-level' -rfka '\'DEBUG\' \'INFO\' \'WARN\' \'ERROR\''
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" help' -l 'help'
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_positional "defaultasflag-test" -eq 1' -F
complete -c 'defaultasflag-test' -n '__defaultasflag-test_should_offer_completions_for_flags_or_options "defaultasflag-test" h help' -s 'h' -l 'help' -d 'Show help information.'
Expand Down