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

Print choices in help? #21

Open
Poldraunic opened this issue Jan 15, 2025 · 0 comments
Open

Print choices in help? #21

Poldraunic opened this issue Jan 15, 2025 · 0 comments

Comments

@Poldraunic
Copy link

choices() function gives programmer an ability to set list of valid values for this option. This is neat because it moves burden of validating input from the programmer to the library.

In my opinion there are currently 2 problems with this:

  1. argumentum doesn't expose choices to the user. If programmer wants to let user know which choices are available they'd have to manually append them to the help(). This is flexible yes, but doesn't scale and leaves room for error.
  2. If user provides value outside of the given choices they get rather useless error message (Error: The value is not in the list of valid values: '--language') that also doesn't specify acceptable values.

It would be great if library could expose these choices automagically. To keep compatibility with existing code we can add additional parameter to choices() function that accepts bool (personally I'd prefer enum) that controls this behaviour with default value to indicate 'off'.

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