Skip to content

fix: mistyped sub commands silently running the no-arg command - #211

Open
DragonL0508 wants to merge 1 commit into
FairyProject:v0.7from
DragonL0508:fix/command-no-arg-fallback
Open

DragonL0508 wants to merge 1 commit into
FairyProject:v0.7from
DragonL0508:fix/command-no-arg-fallback

Conversation

@DragonL0508

Copy link
Copy Markdown

When no sub command matches the arguments, BaseCommand falls back to the no-arg command (@Command("#")) without looking at how many arguments were given. It is then the only candidate, so findSubCommand returns it without isProbableMatch. /shop selll opens the same thing as /shop, and the sender never finds out about the typo.

The fallback now only happens when the no-arg command can take that many arguments (a @Wildcard no-arg command still takes anything). Otherwise there is no match and onHelp shows the usage, as it already does for commands without a no-arg command. As a side effect, a no-arg command without parameters no longer hides the sub command names from tab completion.

Tests: NoArgCommandFallbackTest (no arguments runs the no-arg command, a sub command is still found, a typo shows help). It adds a CoreTestingHandle to core-command's tests, the same as in core-storage.

🤖 Generated with Claude Code

When no sub command matches the arguments, BaseCommand falls back to
the no-arg command (@command("#")) without looking at how many
arguments were given, and since it is the only candidate,
isProbableMatch is skipped as well. "/shop selll" therefore opens the
same thing as "/shop", and the sender never learns about the typo.

Only fall back when the no-arg command can take that many arguments;
otherwise there is no match and onHelp shows the usage, as it already
does for commands without a no-arg command. This also stops the
fallback from hiding sub command names from tab completion when the
no-arg command takes no arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant