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
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:
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.
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'.
The text was updated successfully, but these errors were encountered:
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:
help()
. This is flexible yes, but doesn't scale and leaves room for error.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 acceptsbool
(personally I'd preferenum
) that controls this behaviour with default value to indicate 'off'.The text was updated successfully, but these errors were encountered: