-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add minPositional and maxPositional fields to ArgParser #20042
Comments
Yeah, this has been in the back of my mind for a while. What I'd really like is for ArgParser to have support for parsing arguments and not just options. It should be able to pull out mandatory positional arguments too. I've always had that in mind (which is why the package is "args" and not "options"!) I just haven't gotten there. Supporting this directly would let args do the validation, and would also let it generate a nice usage line for the command. |
This comment was originally written by @seaneagan Positional arguments are fully supported in: https://pub.dartlang.org/packages/unscripted Maybe you can port some of it to It has an internal https://github.com/seaneagan/unscripted/blob/master/lib/src/usage.dart#L50 It also has a https://github.com/seaneagan/unscripted/blob/master/lib/src/usage.dart#L63 These are all validated upon parsing. They are also used in help text like so: $ foo.dart --help Usage: foo.dart [<options>] <valueHelp1> <valueHelp2> <restValueHelp>... <valueHelp1> <help1> Options: ... They are also used in unscripted's tab-completion support. Unscripted does not support optional positionals since dart methods cannot (yet) have both optional named and optional positional arguments, and so supporting optional positionals would mean no "--" options could be added, but presumably parser |
This comment was originally written by @seaneagan One clarification, Also, in unscripted I'm considering disallowing adding both positionals and sub-commands to the same Usage (ArgParser in |
This comment was originally written by @seaneagan Moved to github: |
This issue has been moved to dart-lang/args#31. |
It's not too difficult to handle argument length validation, but it would be nice if ArgParser had some built-in support for it, especially if it included automatically generating nice error messages.
The text was updated successfully, but these errors were encountered: