Skip to content

Default command does not change help script #53

@PythonCoderAS

Description

@PythonCoderAS

If I define two commands and mark one default, the returned help text via cli.js --help shows the arguments as if no command was called even though I can supply an argument.

repro.js:

const sade = require("sade");

const cli = sade("test")
  .command("something <a>", undefined, { default: true })
  .action((a) => console.log(a))
  .command("somethingelse <b>")
  .action((b) => console.log(b));

cli.parse(process.argv);
$ node dist/repro.js --help

  Usage
    $ test <command> [options]

  Available Commands
    something        
    somethingelse    

  For more info, run any command with the `--help` flag
    $ test something --help
    $ test somethingelse --help

  Options
    -v, --version    Displays current version
    -h, --help       Displays this message
$ node dist/repro.js

  ERROR
    Insufficient arguments!

  Run `$ test something --help` for more info.
$ node dist/repro.js something --help

  Usage
    $ test something <a> [options]

  Options
    -h, --help    Displays this message
$ node dist/repro.js something

  ERROR
    Insufficient arguments!

  Run `$ test something --help` for more info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions