-
Notifications
You must be signed in to change notification settings - Fork 36
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
equivalent of python argparse choices? #39
Comments
No, but it's rather easy to implement it without much extra typing compared to a built-in version: using ArgParse
function main(args)
s = ArgParseSettings("Example of choice")
choices = ["1/3", "1/2", "2/3", "3/4", "3/5", "4/5", "5/6",
"7/9", "8/9", "9/10", "25/36", "26/45"]
@add_arg_table s begin
"--rate"
default = "2/3"
range_tester = (x->x ∈ choices)
help = "rate; must be one of " * join(choices, ", ", " or ")
end
parsed_args = parse_args(args, s)
@show parsed_args["rate"]
end
main(ARGS)
|
Thanks for the example @carlobaldassi. Still, it would be convenient to have |
+1 for this feature. |
I would also like to see |
I think this is the biggest reason to have this feature built-in, so that the error can be automatically generated without the programmer's intervention. |
Is there an equivalent to python argparse choice, e.g.:
The text was updated successfully, but these errors were encountered: