-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
How can I ensure that exactly one argument has been supplied? #1000
Comments
There is not currently error detection for excess arguments, and it is not currently easy to handle it yourself in a general way. In simple cases you can check the argument count of the original arguments ( #749 covers the case with extra arguments passed to subcommands. |
v4.0.0-0 prerelease published: #1067 |
v4.0.0 has been released with a fix for Hopefully more useful now! Feel free to open a new issue if still problems, with new information and renewed interest. |
I've tried defining a command with a single required argument, and attempted to validate that exactly one source specified:
And running the program with no arguments, correctly prints 'Invalid arguments' since
program.args.length
is 0. But with 1 argument (program a
)program.args.length
is 2!? and outputs the following, claiming thatprogram.args.length
is 2!?Weirdly running with four arguments
program a b c d
also appears to drop theb
argument somehow:So I guess I have two questions:
The text was updated successfully, but these errors were encountered: