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

Provide info about default values on the main github page #884

Closed
mprinc opened this issue Oct 28, 2018 · 7 comments
Closed

Provide info about default values on the main github page #884

mprinc opened this issue Oct 28, 2018 · 7 comments
Labels
docs README (or other docs) could be improved

Comments

@mprinc
Copy link

mprinc commented Oct 28, 2018

No description provided.

@shadowspawn
Copy link
Collaborator

What sort of info about default values are you looking for?

There are a coupe of examples of default values for options that are covered without additional explanation in the README:

  .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')

  .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')

@mprinc
Copy link
Author

mprinc commented Oct 30, 2018

Thanks. Yes I discovered them eventually, but at the moment I was interested to provide a default value in my app, I couldn't search for any explicitly mentioned default use case, but rather hitting:

.command('list', 'list packages installed', {isDefault: true})

or

If you want to display help by default ..

It would be nice to have more clear directions

@stogoh
Copy link

stogoh commented Dec 7, 2018

And how can i set a option on by default. For example I have an option --databaseHost which should have a default value. How can I do this? This is without an enum.

@ozbillwang
Copy link

I am looking similar to set default value for the parameters.

I used package argparse before, and it is easy to set the default value, how can I do the same with commander?

bar.addArgument(
  [ '-f', '--foo' ],
  {
    action: 'store',
    defaultValue: "test.txt",
    help: 'foo3 bar3'
  }
);

@shadowspawn shadowspawn added the docs README (or other docs) could be improved label Apr 23, 2019
@shadowspawn
Copy link
Collaborator

@ozbillwang

  .option('-f, --foo <value>', 'foo3 bar3', 'test.txt')

@shadowspawn
Copy link
Collaborator

I have proposed a large update to options coverages in README in #953

@shadowspawn
Copy link
Collaborator

Updated README to clarify option types, including section for default option value
https://github.com/tj/commander.js#default-option-value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs README (or other docs) could be improved
Projects
None yet
Development

No branches or pull requests

4 participants