diff --git a/fish.go b/fish.go index 67122c9fe7..588e070eab 100644 --- a/fish.go +++ b/fish.go @@ -171,6 +171,10 @@ func fishAddFileFlag(flag Flag, completion *strings.Builder) { if f.TakesFile { return } + case *PathFlag: + if f.TakesFile { + return + } } completion.WriteString(" -f") } diff --git a/fish_test.go b/fish_test.go index a4c1871438..4ca8c47903 100644 --- a/fish_test.go +++ b/fish_test.go @@ -7,6 +7,10 @@ import ( func TestFishCompletion(t *testing.T) { // Given app := testApp() + app.Flags = append(app.Flags, &PathFlag{ + Name: "logfile", + TakesFile: true, + }) // When res, err := app.ToFishCompletion() diff --git a/testdata/expected-fish-full.fish b/testdata/expected-fish-full.fish index b18d51e8fe..dc41e5aa9a 100644 --- a/testdata/expected-fish-full.fish +++ b/testdata/expected-fish-full.fish @@ -12,6 +12,7 @@ end complete -c greet -n '__fish_greet_no_subcommand' -l socket -s s -r -d 'some \'usage\' text' complete -c greet -n '__fish_greet_no_subcommand' -f -l flag -s fl -s f -r complete -c greet -n '__fish_greet_no_subcommand' -f -l another-flag -s b -d 'another usage text' +complete -c greet -n '__fish_greet_no_subcommand' -l logfile -r complete -c greet -n '__fish_greet_no_subcommand' -f -l help -s h -d 'show help' complete -c greet -n '__fish_greet_no_subcommand' -f -l version -s v -d 'print the version' complete -c greet -n '__fish_seen_subcommand_from config c' -f -l help -s h -d 'show help'