equal
deleted
inserted
replaced
9 ) |
9 ) |
10 |
10 |
11 func genFishComp(buf io.StringWriter, name string, includeDesc bool) { |
11 func genFishComp(buf io.StringWriter, name string, includeDesc bool) { |
12 // Variables should not contain a '-' or ':' character |
12 // Variables should not contain a '-' or ':' character |
13 nameForVar := name |
13 nameForVar := name |
14 nameForVar = strings.Replace(nameForVar, "-", "_", -1) |
14 nameForVar = strings.ReplaceAll(nameForVar, "-", "_") |
15 nameForVar = strings.Replace(nameForVar, ":", "_", -1) |
15 nameForVar = strings.ReplaceAll(nameForVar, ":", "_") |
16 |
16 |
17 compCmd := ShellCompRequestCmd |
17 compCmd := ShellCompRequestCmd |
18 if !includeDesc { |
18 if !includeDesc { |
19 compCmd = ShellCompNoDescRequestCmd |
19 compCmd = ShellCompNoDescRequestCmd |
20 } |
20 } |
36 set -l lastArg (string escape -- (commandline -ct)) |
36 set -l lastArg (string escape -- (commandline -ct)) |
37 |
37 |
38 __%[1]s_debug "args: $args" |
38 __%[1]s_debug "args: $args" |
39 __%[1]s_debug "last arg: $lastArg" |
39 __%[1]s_debug "last arg: $lastArg" |
40 |
40 |
41 set -l requestComp "$args[1] %[3]s $args[2..-1] $lastArg" |
41 # Disable ActiveHelp which is not supported for fish shell |
|
42 set -l requestComp "%[9]s=0 $args[1] %[3]s $args[2..-1] $lastArg" |
42 |
43 |
43 __%[1]s_debug "Calling $requestComp" |
44 __%[1]s_debug "Calling $requestComp" |
44 set -l results (eval $requestComp 2> /dev/null) |
45 set -l results (eval $requestComp 2> /dev/null) |
45 |
46 |
46 # Some programs may output extra empty lines after the directive. |
47 # Some programs may output extra empty lines after the directive. |
194 # which provides the program's completion choices. |
195 # which provides the program's completion choices. |
195 complete -c %[2]s -n '__%[1]s_prepare_completions' -f -a '$__%[1]s_comp_results' |
196 complete -c %[2]s -n '__%[1]s_prepare_completions' -f -a '$__%[1]s_comp_results' |
196 |
197 |
197 `, nameForVar, name, compCmd, |
198 `, nameForVar, name, compCmd, |
198 ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp, |
199 ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp, |
199 ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs)) |
200 ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, activeHelpEnvVar(name))) |
200 } |
201 } |
201 |
202 |
202 // GenFishCompletion generates fish completion file and writes to the passed writer. |
203 // GenFishCompletion generates fish completion file and writes to the passed writer. |
203 func (c *Command) GenFishCompletion(w io.Writer, includeDesc bool) error { |
204 func (c *Command) GenFishCompletion(w io.Writer, includeDesc bool) error { |
204 buf := new(bytes.Buffer) |
205 buf := new(bytes.Buffer) |