Skip to content

Print choices in help? #21

@Poldraunic

Description

@Poldraunic

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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions