-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Unable to use consistent option names between program and subcommand #1616
Comments
Is your "parent command" effectively an independent command with its own options separate from the subcommands? (I think so from your example.) A tidy way of doing this is moving your "parent command" to a subcommand, and making this new subcommand the default command using https://github.com/tj/commander.js/blob/master/examples/defaultCommand.js |
Oooooh I never thought about that. Ok I'll give that a go now! Thanks for the prompt response! |
Works a treat! For future reference this was the working code: program
- .name('foo')
+ .command('foo', { isDefault: true })
.usage('[global options] <file-paths>...')
.option(
'-t, --transform <value>',
'The transform to run, will prompt for a transform if not provided and no module is passed',
)
.action((options, command) => main(command.args, options)); |
Hi there 👋
I've noticed that I'm unable to use an option in a subcommand if the option's name is already in use by the parent command.
My aim to use consistent language across both commands.
Output:
If I comment out the "transform" option on the parent I get the expected result.
Reproducible on versions: 7.2.0 & 8.2.0
The text was updated successfully, but these errors were encountered: