Closed
Description
Are parent's options available to subcommands? In my tests, they aren't.
It would be nice to have them available. In my case is for configuring the remote server my CLI app needs to connect to, so I have not to define the same options in every subcommand.
# ./cmd
#!/usr/bin/env node
var program = require("commander");
program.version("0.0.1")
.option("-H, --host <host>", "server host")
.command("sub", "subcommand");
program.parse(process.argv);
console.log(program.host);
# ./cmd-sub
#!/usr/bin/env node
var program = require("commander");
program.version("0.0.1");
program.parse(process.argv);
console.log(program.host);
And if you run them:
$ ./cmd --host localhost
localhost
$ ./cmd-sub --host localhost
error: unknown option `--host'
Any trick to get them from the subcommand or is just not possible?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels