-
Notifications
You must be signed in to change notification settings - Fork 9
Description
You mention that you'd accept a PR for combined boolean short flags (-a -b ~= -ab). What is your appetite for these features:
- Argument type assertions. E.g., if the default value is
time.Time, the value is returned as atime.Time). Generics may keep this addition small (LOC) - Choices: if the default value is an array, then only values from the array are accepted as valid. E.g.
infoCommand.AddArg("subjects...", ["chemistry", "physics", "algorithms") command, err := registry.Parse([]string{"--subjects", "poetry"}) // err => InvalidChoiceError{Arg: "subjects", Value: "poetry"}
- Mandatory/optional. Mandatory flags must be provided, or result in a parsing error. The most backwards-compatible API change would be adding a function,
AddReqFlag().
My priority preference are in that order: combined short bool flags, types, and choices. Mandatory flags, I'm not strongly opinionated about, as it's easily enough handled outside the library. But I think the first three -- with Go's new support for generics -- would be relatively minor and easily backwards-compatible.
If you're open to PRs, I'll have a crack at all of them; if you have an opinion on how they look, I'd rather discuss up front than have to change the design at merge time. The biggest impact would be a dependency on Go 1.19+.
Combined short flags is straightforward, API-wise. Type assertions and choices, I think can be added without changing the current API at all.