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

add unrecognizedOption handler, or group them on argv #1413

Closed
kellyselden opened this issue Aug 26, 2019 · 4 comments
Closed

add unrecognizedOption handler, or group them on argv #1413

kellyselden opened this issue Aug 26, 2019 · 4 comments

Comments

@kellyselden
Copy link
Contributor

kellyselden commented Aug 26, 2019

I have a feature request after searching the past issues here. My use case is the following:

I have a CLI in front of another CLI. I want to handle some of the incoming options, and then pass the remaining options on. I do not know what the remaining options could be.

I can think of three ways to solve this.

  1. Utilize the -- separator. This could work, but I don't want to confuse the consumers of the first CLI of which options go on which side.
  2. Start deleting recognized options off the resulting argv until only unrecognized are remaining.
  3. Put a new group of unrecognized on the resulting argv. Even though yargs is smart enough to parse unrecognized options and put them on argv, they are ungrouped and indistiguishable (to the best of my knowledge) from recognized options. Putting them in a new unrecognized group would solve this.
  4. Add a new handler function unrecognizedOption. I could then store these for later invoking the second CLI.

I look forward to your response!

@bcoe
Copy link
Member

bcoe commented Aug 26, 2019

I think this is related to @henderea's work here: yargs/yargs-parser#181

@kellyselden
Copy link
Contributor Author

My searching failed to come up with this. It looks perfect. Thanks!

@bcoe
Copy link
Member

bcoe commented Aug 26, 2019

@kellyselden feel free to try out @henderea's branch, and provide some review ... sorry it's taking me a while to land, ETOOMUCHWORK.

@henderea
Copy link

Probably the reason you didn't find it is because it's on the yargs-parser repo, rather than this yargs repo. My original ticket here that I created the PR to cover is #1243, which probably didn't quite match your searches. The actual code change is 100% in the parser, so that's why the PR is there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants