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

Sets the optional parameters of the option #1328

Closed
zeroicey opened this issue Aug 9, 2020 · 4 comments
Closed

Sets the optional parameters of the option #1328

zeroicey opened this issue Aug 9, 2020 · 4 comments

Comments

@zeroicey
Copy link

zeroicey commented Aug 9, 2020

Set the default value. The required parameter should be changed to [Type]

@shadowspawn
Copy link
Collaborator

shadowspawn commented Aug 9, 2020

(Assuming you are talking about the example in the README...)

The example works fine with a required value of <type>?
Or does the comment not describe the behaviour very well, perhaps "specify the cheese topping"?

program
  .option('-c, --cheese <type>', 'add the specified type of cheese', 'blue');

https://github.com/tj/commander.js/blob/master/examples/options-defaults.js

@zeroicey
Copy link
Author

zeroicey commented Aug 11, 2020

I'm sorry That I didn't fully understand the role of <type>

There is nothing wrong with this program. It may be that my requirements are related to the optional parameters that cause unnecessary errors

I think when I use this option I can pass no arguments and use the default values

Excuse me. Have a nice day

@shadowspawn
Copy link
Collaborator

This option has a required value: -c, --cheese <type>. If the option is used then you must supply the value.

example
example -c blue
example -cblue
example --cheese blue
example --cheese=blue
example --cheese   <-- error, value not specified

This option has an optional value, it can be used just as a boolean flag or with a value: -c, --cheese [type]

example
example --cheese
example --cheese blue

@shadowspawn
Copy link
Collaborator

Closing this as resolved.

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

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

2 participants