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

Default command does not parse flags #463

Closed
tandrewnichols opened this issue Oct 29, 2015 · 4 comments
Closed

Default command does not parse flags #463

tandrewnichols opened this issue Oct 29, 2015 · 4 comments

Comments

@tandrewnichols
Copy link
Contributor

I have a feeling this may be an open issue somewhere, but I was unable to find it. I apologize if it is.

If you use a default command (e.g. .command('*')), options are not parsed for this command. So for example:

program
  .command('*')
  .option('-c, --count [count]', 'Do this [count] times')
  .action(function(arg, options) {
    console.log(options);
  });

The logged options object looks like it always does in a command except, if you pass -c or --count, options.count is undefined.

@tandrewnichols
Copy link
Contributor Author

Ah, if you put the option before the command, it does work. E.g.

program
  .option('-c, --count [count]', 'Do this [count] times')
  .command('*')
  .action(function(arg, options) {
    console.log(options);
  });

That's totally acceptable though possibly counter-intuitive. I'll leave this open for now in case you agree and want to make it work the other way around too, but feel free to close if not.

@mfowlewebs
Copy link

Looks like a dupe of #461 I think? Nice workaround.

@tandrewnichols
Copy link
Contributor Author

Yeah, probably caused by the same "bug" (or feature).

@shadowspawn
Copy link
Collaborator

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

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