Skip to content

chore(fish): say what -f does in fishAddFileFlag - #2504

Merged
Juneezee merged 1 commit into
urfave:mainfrom
vidigoat:docs/fish-file-flag-comment
Oct 25, 2026
Merged

Juneezee merged 1 commit into
urfave:mainfrom
vidigoat:docs/fish-file-flag-comment

Conversation

@vidigoat

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • cleanup

What this PR does / why we need it:

Follow-up to the review of #2500. The comment in fishAddFileFlag described the type switch that the takesFile method replaced ("TakesFile is a field of every flag type, not only StringFlag and StringSliceFlag"), which only makes sense next to the old code.

  • fish.go: the comment now says what -f does, worded as suggested in the review: -f stops fish from completing file names for the flag's value. It sits above the -f it describes. fish's complete documentation says the same thing about -f / --no-files: "This completion may not be followed by a filename."

No behavior change: the generated fish script is the same, and the example binary is the same size (only the line table differs, since the if moved up one line).

Which issue(s) this PR fixes:

None, a review suggestion on #2500.

Testing

  • make (generate, vet, tests, binary size, gfmrun), make lint and make v3diff pass. go test -race passes, as do the tests with urfave_cli_no_template, urfave_cli_no_docs and urfave_cli_no_suggest.
  • Built the example CLI with Go 1.27.3 for linux/amd64 on main and on this branch: both binaries are 3,747,964 bytes.

The change was written with Claude Code (AI).

Release Notes

NONE

🤖 Generated with Claude Code

The comment described the type switch that the takesFile method
replaced in urfave#2500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vidigoat
vidigoat requested a review from a team as a code owner October 25, 2026 14:19

@Juneezee Juneezee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The new comment is accurate:

cli/fish.go

Lines 163 to 169 in a2cf6e0

func fishAddFileFlag(flag Flag, completion *strings.Builder) {
if f, ok := flag.(interface{ takesFile() bool }); ok && f.takesFile() {
return
}
// -f stops fish from completing file names for the flag's value
completion.WriteString(" -f")
}

Checked with fish 4.9.3: -f only stops file names for the flag's own value. complete -C 'app --name ' lists nothing for a StringFlag, while complete -C 'app --verbose ' (a BoolFlag, also -f) still lists files for the next argument.

@Juneezee
Juneezee merged commit 7cf94f0 into urfave:main Oct 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants