Repository navigation
fix(help): --name and --fsx-lifecycle show their type as the placeholder; gate every flag (#1520) - #1541
Merged
Conversation
…der; gate every flag (#1520) pflag takes the first back-quoted span in a usage as the flag's value name, so --name printed as '--name spawn launch <name>' and --fsx-lifecycle as '--fsx-lifecycle spawn terminate'. Quote the commands plainly, and add a gate over every spawn and spored flag: the value name --help shows must be the one pflag derives from the flag's type. Fixes #1520
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Live check at |
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.
spawn launch --helpprinted--name spawn launch <name>and--fsx-lifecycle spawn terminate. pflag'sUnquoteUsagetakes the first back-quoted span in a flag's usage as its value name, and both usages put a command in backticks. The commands are now in plain single quotes, so the lines read--name stringand--fsx-lifecycle string.Gate
TestFlagUsagePlaceholderIsTypeNameincmd/flag_usage_backticks_test.gowalks every flag of every command underrootCmd. A sibling test incmd/spored/flag_usage_placeholder_test.gowalks every command under spored'snewRootCmd().The rule: the value name
--helpshows (pflag.UnquoteUsage) must equal the name pflag derives from the flag's type. The test gets that name by asking pflag about a copy of the flag with its backticks removed, which givesstring,int,duration,strings, and""for a bool. It does not keep a list of type names, so a new flag type cannot trip it.`spored`becomes a placeholder just as wrongly, and a space-only rule lets it through. A placeholder with a space still gets its own error message, because that is always this bug.TestBoolFlagUsageHasNoValueName), which stays.Revert evidence
main:--fsx-lifecycle:`spored`gives--help shows the value name "spored", want the type name "string".`spawn pool`injected intopool-worker --run-id:spored pool-worker --run-id: --help shows the value name "spawn pool", want the type name "string".Checks (all pass, tree clean after regeneration)
make checkgo test ./...with the AWS env strippedmake test-e2e-tier0semgrep scan --config=auto --error .make gen-docs(docs-gen/launch.mdregenerated and committed)make api-snapshotmake cli-iam-actionsFixes #1520