Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: Feature appetite #1

Open
xxxserxxx opened this issue Sep 22, 2022 · 0 comments
Open

Discussion: Feature appetite #1

xxxserxxx opened this issue Sep 22, 2022 · 0 comments

Comments

@xxxserxxx
Copy link

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 a time.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant