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

Pass unknown also as a second argument to the command:* event #921

Closed
negiDharmendra opened this issue Feb 25, 2019 · 5 comments
Closed

Comments

@negiDharmendra
Copy link

We are trying to use this awesome library to handle command line arguments and flags in Taiko.

Example:

taiko [option] --> this opens an interactive repl.
taiko <js file> [option]  --> executes the js script.

There seems to be an issue related to unknown flags. When we provide the js file argument and pass an unknown flag commander does not complain about that. But when we pass only unknown flag without arguments commander prints a nice message that provides flag was invalid.

It would be great if the commander complains about the unknown flags even if they are passed after arguments.

@negiDharmendra
Copy link
Author

In order to fix the issue, we need to pass the unknown parameter to the while emitting the 'command:*' event on the following file.

this.emit('command:*', args);

@shadowspawn
Copy link
Collaborator

Have you got a small example program?

(I do see the warning for unknown flags in my program which has subcommands, but looks like you have just an optional argument and options and no subcommands?)

@clarsen
Copy link
Contributor

clarsen commented May 23, 2019

Attached is a PR that does the suggested behavior and adjustment of tests. I'm a little hesitant about it though because it breaks the existing default behavior of ignoring unknown options, instead resulting in an error.

While this is the desired behavior for my programs, others might be relying on the silent default handling of unknown options.

@shadowspawn
Copy link
Collaborator

I have reproduced this, and realised it is a duplicate of #561. Closing in favour of that open issue.

Thank you for your contributions.

@shadowspawn
Copy link
Collaborator

After deeper analysis I discovered that there are different behaviours depending on whether there is an action handler attached to the program. #965 is targeting the case when there is an action handler, and original report in #561 covering no action handler. Not sure which case applies to taiko but have an open PR and an open issue to cover the two possibilities, so will still leave this closed.

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

No branches or pull requests

3 participants