I4 [CRIT/CLI] Cross-NS verb redirects + subcommand typo suggestions (audit-I5 + audit-I6)#36
Merged
Merged
Conversation
…stent 'issue ready'
…stent 'issue merge'
…istent 'issue review'
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.
Summary
Two CLI papercuts that turn a typo into a wild-goose chase:
audit-I5: cobra's "Did you mean?" suggestion only fires at the root command's auto-error path. Once execution reaches a parent's
RunE(which I3 landed across every parent), the suggestion machinery is bypassed.shithub reeposuggestsrepo, butshithub pr klose/org liat/repo cregot no help. Now they do — extendedParentRunEto walk the parent's children and Levenshtein-match (or 3+ char prefix-match) against the bad arg.shithub pr klose→Did you mean this? close.audit-I6: the H2 cross-namespace verb redirects help when symmetric verbs (
view,close,reopen,edit) hit the wrong side —shithub pr close 1on an issue saystry 'shithub issue close 1'. But the same template fires for asymmetric PR-only verbs (pr ready,pr merge,pr review), suggestingshithub issue ready 1— a command that doesn't exist. The user chases a dead command. Added anAsymmetricflag toErrWrongNamespace+ aCheckAsymmetrichelper; the three PR-only callers now emit:instead of the misleading
try shithub issue ready 1redirect.Test plan
TestParentRunE_LevenshteinSuggestion—klose→closeTestParentRunE_PrefixSuggestion—cre→createTestParentRunE_NoCloseMatchSkipsSuggestion— far-off typos don't triggerTestParentRunE_HiddenChildrenIgnored— hidden subs stay hiddenTestCheckAsymmetric_PRReadyOnIssue— asymmetric flag suppressesissue readysuggestionTestCheckAsymmetric_PRMergeOnIssue— same forpr mergeTestCheck_StillSuggestsForSymmetricVerb— regression guard: symmetric verbs (pr close) still redirect atissue closeTestReadyWrongNamespaceRedirectsupdated for the new asymmetric messagemake cicleangolangci-lint runcleanshithub pr klose/org liat/repo creall suggest the right verbDesign notes
Checkstays as a thin wrapper aroundCheckAsymmetric(..., false)so the 7 existing call sites for symmetric verbs (issue close, issue edit, issue reopen, pr close, etc.) don't need to change. Only the 3 asymmetric callers (pr ready,pr merge,pr review) opt into the new path.CheckAsymmetricto also drop the symmetric verbs from the issue side onto the PR side (e.g.issue lock→pr lock). H2 already handles those, and issue→PR asymmetry isn't in the I-audit.