You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No way to mark a single-value argument as required #2392
Are you running the latest v3 release? The list of releases is here.
Did you check the manual for your release? The v3 manual is here.
Did you perform a search about this feature? Here's the GitHub guide about searching.
What problem does this solve?
Version: urfave/cli v3.10.1 (also on latest main at commit 4937c16)
There is no way to require a single-value argument ({Type}Arg). ArgumentBase.Parse falls back to the default value when no argument is given, so a command like app delete runs with an empty ID instead of failing.
The closest workaround is the plural type with Min/Max:
With Required: true, Parse returns Required argument "id" not set when the argument is missing.
Help output could also follow the bracket convention that {Type}Args already uses: [name] when optional, name when required. Today single args always render as name even though they are optional. This changes the expectation in TestArgUsage from ia to [ia]; no other test encodes the current rendering.
Describe alternatives you've considered
Making ArgumentBase.Parse error when the argument is missing, without a new field. That would be a breaking change — the fallback to Value is intentional (TestSingleOptionalArg).
A Min field like the plural type has. On a single value it can only ever be 0 or 1, so a bool seemed like a better fit.
Activity