[go: nahoru, domu]

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

Output positional command arguments defaults in help output #2012

Open
RavenHursT opened this issue Aug 21, 2021 · 0 comments
Open

Output positional command arguments defaults in help output #2012

RavenHursT opened this issue Aug 21, 2021 · 0 comments

Comments

@RavenHursT
Copy link
RavenHursT commented Aug 21, 2021

I have the following yargs configuration:

yargs(hideBin(process.argv))
  .command(
    'serve [port]',
    'Start the server',
    (yargs) => yargs.positional('port', {
      describe: 'Port to bind on',
      default: 8080
    })
  )
  .alias('v', 'version')
  .version()
  .option('verbose', {
    type: 'boolean',
    description: 'Run with verbose logging'
  }).args

When I run my app w/ --help I get the following:

index.js [command]

Commands:
  index.js serve [port]  start the server

Options:
      --help     Show help                                 [boolean]
      --verbose  Run with verbose logging                  [boolean]
  -v, --version  Show version number                       [boolean]

Process finished with exit code 0

My question is: How do I get the default 8080 for the port argument to be printed into the help output?

I'd like to see an output similar to the (default:[value]) given from the command.js package: https://github.com/tj/commander.js#automated-help

$ node ./examples/pizza --help
Usage: pizza [options]

An application for pizza ordering

Options:
  -p, --peppers        Add peppers
  -c, --cheese <type>  Add the specified type of cheese (default: "marble")
  -C, --no-cheese      You do not want any cheese
  -h, --help           display help for command
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

2 participants