Skip to content

Commit

Permalink
Add type switch
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
  • Loading branch information
saschagrunert committed Aug 26, 2019
1 parent 38d0ac6 commit 0c01922
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions fish.go
Expand Up @@ -164,19 +164,21 @@ func fishAddFileFlag(
flag Flag,
completion *strings.Builder,
) {
addFileExclusionFlag := true
if f, ok := flag.(GenericFlag); ok && f.TakesFile {
addFileExclusionFlag = false
}
if f, ok := flag.(StringFlag); ok && f.TakesFile {
addFileExclusionFlag = false
}
if f, ok := flag.(StringSliceFlag); ok && f.TakesFile {
addFileExclusionFlag = false
}
if addFileExclusionFlag {
completion.WriteString(" -f")
switch f := flag.(type) {
case GenericFlag:
if f.TakesFile {
return
}
case StringFlag:
if f.TakesFile {
return
}
case StringSliceFlag:
if f.TakesFile {
return
}
}
completion.WriteString(" -f")
}

func (a *App) fishSubcommandHelper(allCommands []string) string {
Expand Down

0 comments on commit 0c01922

Please sign in to comment.