You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a command and a sub command with the same option, then when you
invoke program command subcommand -o option the subcommand will not receive
the option.
Expected Behavior
When you invoke program command subcommand -o option the subcommand recieves
the options passed, just like the command does.
Thanks for the detailed description and reproduction.
The default behaviour is that options can come before or after command-arguments, and before or after subcommands. So the first command is eating the option before the subcommand parsing starts.
You can change this behaviour with .enablePositionalOptions(). See the README for some additional description and link to an example file.
(Sometimes this comes up when the top-level command and options are not really hierarchical but a shortcut to the most common use. In this case the command can be made a default command, and the options no longer get used at two levels. See #1616. )
Command and Sub Command with Same Option
Current Behavior
If you have a command and a sub command with the same option, then when you
invoke
program command subcommand -o option
the subcommand will not receivethe option.
Expected Behavior
When you invoke
program command subcommand -o option
the subcommand recievesthe options passed, just like the command does.
Reproduction Repository
https://github.com/jmcdo29/commander-sub-command-same-option-name
Reproduction Steps
pnpm i
node index.js say -m hello
to see the main command outputnode index.js say yellow -m hello
to see the sub command outputTo see that the sub command does work, you can run the command
node main.js say yellow -y hello
.Commander Info
version: 9.4.1
Related Issue
The text was updated successfully, but these errors were encountered: