Skip to content
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

Gracefully handle unspecified args with ArgParser #14786

Closed
sethladd opened this issue Nov 4, 2013 · 8 comments
Closed

Gracefully handle unspecified args with ArgParser #14786

sethladd opened this issue Nov 4, 2013 · 8 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@sethladd
Copy link
Contributor

sethladd commented Nov 4, 2013

It would be nice to have an option in ArgParser to ignore unspecified args.

Use Case:

Build system specifies its own options.
Build system uses another library that specifies its options.

I want to pass args to both the main build system and the included library:

build.dart --my-option --deploy

@sethladd
Copy link
Contributor Author

sethladd commented Nov 4, 2013

Well, I found this in the API docs:

By default, the parse() method stops as soon as it reaches -- by itself or anything that the parser doesn't recognize as an option, flag, or option value. If arguments still remain, they go into ArgResults.rest.

Which looks like it can help me today.

@sethladd
Copy link
Contributor Author

sethladd commented Nov 5, 2013

After playing around the -- doesn't help me because the tools generate the command-line, and they don't put their args after --.

So I think I need a "ignore unspecified args" option for ArgParser.

@sethladd
Copy link
Contributor Author

sethladd commented Nov 5, 2013

Will you accept a patch for such a feature?


cc @munificent.

@munificent
Copy link
Member

Args has an option now to ignore unspecified arguments, but not unrecognized options. The former lets you have options that appear after non-option arguments. For example:

$ myapp some/file.txt --option

Args can skip over some/file.txt and parse --option. But it doesn't do that for things that look like options (i.e. a leading "-").

I'd be fine with a patch for the latter too, provided it was an opt-in feature. I'm thinking add a "ignoreUnknownOptions" argument to parse().

@sethladd
Copy link
Contributor Author

sethladd commented Nov 7, 2013

Thanks Bob. ignoreUnknownOptions as an opt-IN would work. Good to know you'd accept a patch. :)

@anders-sandholm
Copy link
Contributor

Removed Library-Args label.
Added Pkg-Args label.

@sethladd
Copy link
Contributor Author

Now at dart-lang/args#9


Added MovedToGithub label.

@sethladd sethladd added Type-Enhancement P3 A lower priority bug or feature request area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Apr 22, 2015
@DartBot
Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/args#23.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants