Skip to content
Merged
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 @@ -2,8 +2,8 @@ struct FishCompletionsGenerator {
static func generateCompletionScript(_ type: ParsableCommand.Type) -> String {
let programName = type._commandName
let helper = """
function __fish_\(programName)_using_command
set cmd (commandline -opc)
function _swift_\(programName)_using_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq (count $argv) ]
for i in (seq (count $argv))
if [ $cmd[$i] != $argv[$i] ]
Expand All @@ -14,7 +14,7 @@ struct FishCompletionsGenerator {
end
return 1
end

"""

let completions = generateCompletions(commandChain: [programName], [type])
Expand All @@ -37,7 +37,7 @@ struct FishCompletionsGenerator {
}
}

let prefix = "complete -c \(programName) -n '__fish_\(programName)_using_command"
let prefix = "complete -c \(programName) -n '_swift_\(programName)_using_command"
/// We ask each suggestion to produce 2 pieces of information
/// - Parameters
/// - ancestors: a list of "ancestor" which must be present in the current shell buffer for
Expand Down
62 changes: 31 additions & 31 deletions Tests/ArgumentParserExampleTests/MathExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ _math
"""

private let fishCompletionScriptText = """
function __fish_math_using_command
set cmd (commandline -opc)
function _swift_math_using_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq (count $argv) ]
for i in (seq (count $argv))
if [ $cmd[$i] != $argv[$i] ]
Expand All @@ -557,33 +557,33 @@ function __fish_math_using_command
end
return 1
end
complete -c math -n '__fish_math_using_command math' -f -l version -d 'Show the version.'
complete -c math -n '__fish_math_using_command math' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math' -f -a 'add' -d 'Print the sum of the values.'
complete -c math -n '__fish_math_using_command math' -f -a 'multiply' -d 'Print the product of the values.'
complete -c math -n '__fish_math_using_command math' -f -a 'stats' -d 'Calculate descriptive statistics.'
complete -c math -n '__fish_math_using_command math' -f -a 'help' -d 'Show subcommand help information.'
complete -c math -n '__fish_math_using_command math add' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
complete -c math -n '__fish_math_using_command math add' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math multiply' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
complete -c math -n '__fish_math_using_command math multiply' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math stats' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math stats' -f -a 'average' -d 'Print the average of the values.'
complete -c math -n '__fish_math_using_command math stats' -f -a 'stdev' -d 'Print the standard deviation of the values.'
complete -c math -n '__fish_math_using_command math stats' -f -a 'quantiles' -d 'Print the quantiles of the values (TBD).'
complete -c math -n '__fish_math_using_command math stats' -f -a 'help' -d 'Show subcommand help information.'
complete -c math -n '__fish_math_using_command math stats average' -f -r -l kind -d 'The kind of average to provide.'
complete -c math -n '__fish_math_using_command math stats average --kind' -f -k -a 'mean median mode'
complete -c math -n '__fish_math_using_command math stats average' -f -l version -d 'Show the version.'
complete -c math -n '__fish_math_using_command math stats average' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math stats stdev' -f -s h -l help -d 'Show help information.'
complete -c math -n '__fish_math_using_command math stats quantiles' -f -r -l file
complete -c math -n '__fish_math_using_command math stats quantiles --file' -f -a '(for i in *.{txt,md}; echo $i;end)'
complete -c math -n '__fish_math_using_command math stats quantiles' -f -r -l directory
complete -c math -n '__fish_math_using_command math stats quantiles --directory' -f -a '(__fish_complete_directories)'
complete -c math -n '__fish_math_using_command math stats quantiles' -f -r -l shell
complete -c math -n '__fish_math_using_command math stats quantiles --shell' -f -a '(head -100 /usr/share/dict/words | tail -50)'
complete -c math -n '__fish_math_using_command math stats quantiles' -f -r -l custom
complete -c math -n '__fish_math_using_command math stats quantiles --custom' -f -a '(command math ---completion stats quantiles -- --custom (commandline -opc)[1..-1])'
complete -c math -n '__fish_math_using_command math stats quantiles' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math' -f -l version -d 'Show the version.'
complete -c math -n '_swift_math_using_command math' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math' -f -a 'add' -d 'Print the sum of the values.'
complete -c math -n '_swift_math_using_command math' -f -a 'multiply' -d 'Print the product of the values.'
complete -c math -n '_swift_math_using_command math' -f -a 'stats' -d 'Calculate descriptive statistics.'
complete -c math -n '_swift_math_using_command math' -f -a 'help' -d 'Show subcommand help information.'
complete -c math -n '_swift_math_using_command math add' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
complete -c math -n '_swift_math_using_command math add' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math multiply' -f -l hex-output -s x -d 'Use hexadecimal notation for the result.'
complete -c math -n '_swift_math_using_command math multiply' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math stats' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math stats' -f -a 'average' -d 'Print the average of the values.'
complete -c math -n '_swift_math_using_command math stats' -f -a 'stdev' -d 'Print the standard deviation of the values.'
complete -c math -n '_swift_math_using_command math stats' -f -a 'quantiles' -d 'Print the quantiles of the values (TBD).'
complete -c math -n '_swift_math_using_command math stats' -f -a 'help' -d 'Show subcommand help information.'
complete -c math -n '_swift_math_using_command math stats average' -f -r -l kind -d 'The kind of average to provide.'
complete -c math -n '_swift_math_using_command math stats average --kind' -f -k -a 'mean median mode'
complete -c math -n '_swift_math_using_command math stats average' -f -l version -d 'Show the version.'
complete -c math -n '_swift_math_using_command math stats average' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math stats stdev' -f -s h -l help -d 'Show help information.'
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l file
complete -c math -n '_swift_math_using_command math stats quantiles --file' -f -a '(for i in *.{txt,md}; echo $i;end)'
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l directory
complete -c math -n '_swift_math_using_command math stats quantiles --directory' -f -a '(__fish_complete_directories)'
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l shell
complete -c math -n '_swift_math_using_command math stats quantiles --shell' -f -a '(head -100 /usr/share/dict/words | tail -50)'
complete -c math -n '_swift_math_using_command math stats quantiles' -f -r -l custom
complete -c math -n '_swift_math_using_command math stats quantiles --custom' -f -a '(command math ---completion stats quantiles -- --custom (commandline -opc)[1..-1])'
complete -c math -n '_swift_math_using_command math stats quantiles' -f -s h -l help -d 'Show help information.'
"""
28 changes: 14 additions & 14 deletions Tests/ArgumentParserUnitTests/CompletionScriptTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ _escaped-command
"""

private let fishBaseCompletions = """
function __fish_base_using_command
set cmd (commandline -opc)
function _swift_base_using_command
set -l cmd (commandline -opc)
if [ (count $cmd) -eq (count $argv) ]
for i in (seq (count $argv))
if [ $cmd[$i] != $argv[$i] ]
Expand All @@ -255,16 +255,16 @@ function __fish_base_using_command
end
return 1
end
complete -c base -n '__fish_base_using_command base' -f -r -l name -d 'The user\\'s name.'
complete -c base -n '__fish_base_using_command base' -f -r -l kind
complete -c base -n '__fish_base_using_command base --kind' -f -k -a 'one two custom-three'
complete -c base -n '__fish_base_using_command base' -f -r -l other-kind
complete -c base -n '__fish_base_using_command base --other-kind' -f -k -a '1 2 3'
complete -c base -n '__fish_base_using_command base' -f -r -l path1
complete -c base -n '__fish_base_using_command base --path1' -f -a '(for i in *.{}; echo $i;end)'
complete -c base -n '__fish_base_using_command base' -f -r -l path2
complete -c base -n '__fish_base_using_command base --path2' -f -a '(for i in *.{}; echo $i;end)'
complete -c base -n '__fish_base_using_command base' -f -r -l path3
complete -c base -n '__fish_base_using_command base --path3' -f -k -a 'a b c'
complete -c base -n '__fish_base_using_command base' -f -s h -l help -d 'Show help information.'
complete -c base -n '_swift_base_using_command base' -f -r -l name -d 'The user\\'s name.'
complete -c base -n '_swift_base_using_command base' -f -r -l kind
complete -c base -n '_swift_base_using_command base --kind' -f -k -a 'one two custom-three'
complete -c base -n '_swift_base_using_command base' -f -r -l other-kind
complete -c base -n '_swift_base_using_command base --other-kind' -f -k -a '1 2 3'
complete -c base -n '_swift_base_using_command base' -f -r -l path1
complete -c base -n '_swift_base_using_command base --path1' -f -a '(for i in *.{}; echo $i;end)'
complete -c base -n '_swift_base_using_command base' -f -r -l path2
complete -c base -n '_swift_base_using_command base --path2' -f -a '(for i in *.{}; echo $i;end)'
complete -c base -n '_swift_base_using_command base' -f -r -l path3
complete -c base -n '_swift_base_using_command base --path3' -f -k -a 'a b c'
complete -c base -n '_swift_base_using_command base' -f -s h -l help -d 'Show help information.'
"""