A mistyped subcommand followed by flags blames the flag:
elastic stack es serch
-> Error: unknown command: serch (correct)
elastic stack es serch --index my-index
-> Error: unknown option '--index' (misleading)
--index is a valid option for the command the user meant. Sending them to look at their flags hides the actual typo.
Commander already handles the bare case correctly, so this is specifically about argument ordering.
Suggested fix: resolve the subcommand before parsing options, so an unrecognized operand is reported as an unknown command regardless of what follows it.
Test plan
A mistyped subcommand followed by flags blames the flag:
--indexis a valid option for the command the user meant. Sending them to look at their flags hides the actual typo.Commander already handles the bare case correctly, so this is specifically about argument ordering.
Suggested fix: resolve the subcommand before parsing options, so an unrecognized operand is reported as an unknown command regardless of what follows it.
Test plan
stack es <typo> --index xerrors withunknown commandunknown option