-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Commander.js version: 2.13.0
The feature "subcommand in dedicated binary" destroys option ordering for boolean longopts. The bug is that, for unknown options, commander always assumes they have an argument. Boolean longopts don't have an argument, so commander assumes the next option to be an argument to the boolean option. Unknown options get sorted to the end of the argument list, so option ordering is nonsensical after the aforementioned wrong assumption has taken place.
Example:
$ ls
somecommand somecommand-subcommand1
Contents of somecommand:
program.command('subcommand1', 'execute subcommand1').
Triggering the bug:
$ ./somecommand subcommand1 --bool-option subcommand2 --subcommand2-option subcommand2-argument
should result in
./somecommand-subcommand1 --bool-option subcommand2 --subcommand2-option subcommand2-argument
being called but commander executes
./somecommand-subcommand1 subcommand2-argument --bool-option subcommand2
This is a serious bug because the usage output cannot be made correct for the user, it is confusing the user and it results in the program not working without user feedback in combination with bug #961 .
It also could lead to random logic being executed if the options are implemented in a specific manner in the subcommand.