Repository navigation
Conversation
A flag with no usage text printed its env var hint one column to the right of every other flag's usage, because the hint always starts with a space. stringifyFlag already trims the space in front of the default text for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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:
A flag with an env var but no usage text printed its env var hint one column to the right of the other flags' usage:
stringifyFlagpasses"<names>\t<usage>"toFlagEnvHinter, andwithEnvHintappends" [$APP_TOKEN]". With no usage, that space is the first thing in the usage column, which the tabwriter aligns.stringifyFlagalready trims the space in front of(default: …)for the same case (strings.TrimSpace(usage + defaultValueString)), but the env hint is added after that.docs.go:withEnvHintleaves out the leading space when the string it is given ends with the tab, i.e. the flag has no usage text. A customFlagEnvHintergets the same string as before.flag_test.go:TestFlagEnvHintWithoutUsagechecks a string flag and a bool flag with two env vars, building the expected hint withwithEnvHintso it holds for the Windows%VAR%form too.TestFlagDefaultValueWithEnvand the*WithEnvVarHelpOutputtests built their expected strings by concatenatingwithEnvHint(envVars, ""), which assumes the hint always starts with a space. They now pass the flag's text towithEnvHint(withEnvHint([]string{"uflag"}, "--flag\t")), or compare against the hint without its leading space.With this change:
Which issue(s) this PR fixes:
None, found while checking the help output of flags with value sources.
Testing
TestFlagEnvHintWithoutUsagefails onmain("--token string\t [$APP_TOKEN]") and passes with this change.make all,make test GFLAGS='--tags urfave_cli_no_template',make lint,make diffcheckandmake v3diffpass, and so do theurfave_cli_no_docsandurfave_cli_no_suggesttags.Release Notes
🤖 Generated with Claude Code