Add type switch

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert 2019-08-26 08:46:55 +02:00
parent 38d0ac6296
commit 0c01922a12
No known key found for this signature in database
GPG Key ID: 8CE029DD1A866E52

26
fish.go
View File

@ -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 {