add additional support for argument aliases.

This commit is contained in:
Tim Reddehase 2018-09-25 13:11:06 +02:00 committed by David Gillies
parent 575081ea12
commit 5697159013
No known key found for this signature in database
GPG key ID: BD350530941BDC96
2 changed files with 11 additions and 1 deletions

View file

@ -50,7 +50,7 @@ func writeFishCommandCompletion(rootCmd, cmd *Command, buf *bytes.Buffer) {
condition := commandCompletionCondition(rootCmd, cmd)
buf.WriteString(fmt.Sprintf("complete -c %s -f %s -a %s -d '%s'\n", rootCmd.Name(), condition, subCmd.Name(), subCmd.Short))
})
for _, validArg := range cmd.ValidArgs {
for _, validArg := range append(cmd.ValidArgs, cmd.ArgAliases...) {
condition := commandCompletionCondition(rootCmd, cmd)
buf.WriteString(
fmt.Sprintf("complete -c %s -f %s -a %s -d '%s'\n",

View file

@ -117,4 +117,14 @@ func TestFishCompletions(t *testing.T) {
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a node`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a service`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a replicationcontroller`)
// check for aliases to positional arguments for a command
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a pods`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a nodes`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a services`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a replicationcontrollers`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a po`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a no`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a svc`)
checkRegex(t, output, `-n '__fish_root_no_subcommand(; and[^']*)?' -a rc`)
}