Repository navigation
fix: honor TakesFile for every flag type in fish completion - #2500
Merged
Juneezee merged 1 commit intoOct 25, 2026
Merged
Conversation
TakesFile is a field of every flag type, but fishAddFileFlag only checked StringFlag and StringSliceFlag, so a GenericFlag or StringMapFlag with TakesFile still got `-f` and fish offered no files for it. v2 also handled GenericFlag. Flags now report it through an unexported method on FlagBase; a flag that takes no value (BoolFlag) keeps `-f`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vidigoat
force-pushed
the
fix/fish-takes-file-all-flag-types
branch
from
October 25, 2026 11:56
304daa0 to
01c93c2
Compare
Juneezee
approved these changes
Oct 25, 2026
Juneezee
left a comment
Member
There was a problem hiding this comment.
Thanks! Reproduced on main with fish 4.9.3: complete -C 'app --input ' (GenericFlag) and complete -C 'app --env-file ' (StringMapFlag) list nothing. With this PR both list files. The new test fails on main and passes here.
A bonus of the method on FlagBase: a user type that embeds a flag, such as type pathFlag struct{ cli.StringFlag }, now gets file completion too. The old type switch missed it.
Optional nit: this comment describes the old code, which readers won't see after the merge:
Line 164 in 01c93c2
Maybe say what -f does instead, e.g. // -f stops fish from completing file names for the flag's value. Fine to merge as is.
Juneezee
pushed a commit
that referenced
this pull request
Oct 25, 2026
The comment described the type switch that the takesFile method replaced in #2500. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What this PR does / why we need it:
TakesFileis a field of every flag type (FlagBase), and its only reader is the fish completion script, butfishAddFileFlagonly checks*StringFlagand*StringSliceFlag. Any other flag withTakesFile: truestill gets-f, so fish completes no files for it:In fish 4.9.3,
complete -C "app --config "lists the files in the directory, whilecomplete -C "app --input "lists nothing. v2'sfishAddFileFlagalso handledGenericFlag(andPathFlag, which v3 replaced withStringFlag+TakesFile).FlagBasenow has an unexportedtakesFile()(TakesFileand the flag takes a value), andfishAddFileFlagchecks for it instead of the two concrete types. So every flag type works, there is no API change (make v3diffis clean), and aBoolFlagwithTakesFilekeeps-f, as it does now, since it has no value to complete.Which issue(s) this PR fixes:
None, found while testing the generated fish script in fish.
Testing
TestFishCompletionTakesFileForAllFlagTypes(StringFlag,GenericFlag,StringMapFlag, a plainStringFlagand aBoolFlag). It fails onmain.--inputand--env-filenow complete files like--config.make(generate, vet, tests, binary size, gfmrun),make lintandmake v3diffpass.go test -racepasses, as do the tests withurfave_cli_no_template,urfave_cli_no_docsandurfave_cli_no_suggest.The change and the test were written with Claude Code (AI).
Release Notes
🤖 Generated with Claude Code