Repository navigation
fix: mistyped sub commands silently running the no-arg command - #211
Open
DragonL0508 wants to merge 1 commit into
Open
DragonL0508 wants to merge 1 commit into
DragonL0508 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When no sub command matches the arguments,
BaseCommandfalls back to the no-arg command (@Command("#")) without looking at how many arguments were given. It is then the only candidate, sofindSubCommandreturns it withoutisProbableMatch./shop selllopens 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
@Wildcardno-arg command still takes anything). Otherwise there is no match andonHelpshows 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 aCoreTestingHandleto core-command's tests, the same as in core-storage.🤖 Generated with Claude Code