-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot have option named parent #1212
Comments
By default the option values are stored as properties on the command, and there is already an internal property called The good news is the README has a section on a way to resolve this: 🎉 https://github.com/tj/commander.js#avoiding-option-name-clashes In particular:
|
For example: const { Command } = require('commander');
const program = new Command();
program
.storeOptionsAsProperties(false)
.passCommandToAction(false);
program
.command('doit <arg0> <arg1> [arg2]')
.option('-p, --parent <parent_name>', 'add parent option', 'default')
.action(async (arg0, arg1, arg2, options) => {
console.log('PROGRAM', options.parent)
});
program.parse(process.argv); $ node index.js doit a b c
PROGRAM default
$ node index.js doit a b c --parent ppp
PROGRAM ppp |
It works. Thank you for helping me through this. Closing issue. |
Opened a PR to add a warning for option name clashes: #1275 |
Summary
Cannot seem to add an option named parent.
Version
5.0.0-4
Code snippet
Run cmd
foo doit -h
Stack Trace
The text was updated successfully, but these errors were encountered: