Move doc generation flag check to inner part of loop
@@ -115,11 +115,6 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr
func (a *App) prepareFishFlags(flags []Flag, previousCommands []string) []string {
completions := []string{}
for _, f := range flags {
- flag, ok := f.(DocGenerationFlag)
- if !ok {
- continue
- }
-
completion := &strings.Builder{}
completion.WriteString(fmt.Sprintf(
"complete -c %s -n '%s'",
@@ -129,7 +124,7 @@ func (a *App) prepareFishFlags(flags []Flag, previousCommands []string) []string
fishAddFileFlag(f, completion)
- for idx, opt := range flag.Names() {
+ for idx, opt := range f.Names() {
if idx == 0 {
completion.WriteString(fmt.Sprintf(
" -l %s", strings.TrimSpace(opt),
@@ -142,6 +137,7 @@ func (a *App) prepareFishFlags(flags []Flag, previousCommands []string) []string
}
}
+ if flag, ok := f.(DocGenerationFlag); ok {
if flag.TakesValue() {
completion.WriteString(" -r")
}
@@ -150,6 +146,7 @@ func (a *App) prepareFishFlags(flags []Flag, previousCommands []string) []string
completion.WriteString(fmt.Sprintf(" -d '%s'",
escapeSingleQuotes(flag.GetUsage())))
}
+ }
completions = append(completions, completion.String())
}
