cut: declare required positionals through cli arguments - #136
Merged
Conversation
Seventeen commands checked their positional by hand and returned their own "must be given" error. They now declare it through utils.Positional (a required cli.StringArgs, max -1 for an id list), so urfave rejects the run before the action; the argIDs helper goes with them. The missing-argument failure is now the framework's message through the logger with exit code 1 instead of a bare line with 255. image build keeps its exactly-one check (a declared argument ignores extras) and workload dissociate keeps its optional ids.
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
Seventeen commands checked their positional argument by hand and returned their own "must be given" error. They now declare it:
utils.Positional(name, usage, max)builds a requiredcli.StringArgs(urfave/cli v3.11 carriesMin/Maxon the plural type only;max−1 is an id list), 27 commands use it, the actions readcmd.StringArgs(name)and theargIDshelper is gone.Kept as they were:
image build(its rule is exactly one argument, and a declared argument ignores extras) andworkload dissociate(ids are optional when--nodeis given).Behaviour change
A missing argument now fails before the action with urfave's message, printed through the logger with exit code 1, where it used to be a bare line with exit code 255:
Lines
Production −128 net (+63 −191), tests +8 net; comment delta +1 −0 (the helper's godoc carries the −1 convention).
Evidence
Gate on the branch: build, vet, full tests,
make lint,make fmt-checkandaslon both GOOS green; the two tests that pinned the old errors now assert the run fails before the action.