Conversation
Add `alias` field to `CommandMeta` allowing subcommands to be invoked by alternate names (e.g. `i` for `install`). Direct key matches are preferred over alias lookups. Aliases are displayed in help/usage output. Closes #152 Co-Authored-By: 苏向夜 <67710306+fu050409@users.noreply.github.com> Co-Authored-By: Horu <HigherOrderLogic@users.noreply.github.com> Co-Authored-By: TJ <ratiofu@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces alias support for subcommands, enabling commands to be resolved by alternative names. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/main.test.ts (1)
263-266: Use an inline snapshot for usage output assertions.Lines 264-265 currently use substring checks; switch this usage-output test to an inline snapshot to match repo test conventions.
As per coding guidelines, Tests should use inline snapshots for usage output verification.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/main.test.ts` around lines 263 - 266, Replace the two substring assertions that check usage with a single inline snapshot assertion: call renderUsage(command) into the usage variable (as already done) and replace expect(usage).toContain(...) lines with expect(usage).toMatchInlineSnapshot(...). Update the test in the same test block that uses renderUsage/usage/command to assert the full usage output as an inline snapshot (you can run the test to capture the actual usage string or paste the expected usage text into the snapshot).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/main.test.ts`:
- Around line 263-266: Replace the two substring assertions that check usage
with a single inline snapshot assertion: call renderUsage(command) into the
usage variable (as already done) and replace expect(usage).toContain(...) lines
with expect(usage).toMatchInlineSnapshot(...). Update the test in the same test
block that uses renderUsage/usage/command to assert the full usage output as an
inline snapshot (you can run the test to capture the actual usage string or
paste the expected usage text into the snapshot).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 262a9bd9-c344-40c7-8176-b0c7b992c4cb
📒 Files selected for processing (4)
src/command.tssrc/types.tssrc/usage.tstest/main.test.ts
Summary
Adds support for defining aliases on subcommands via
CommandMeta.alias, resolving #152.aliasfield acceptsstring | string[]onCommandMeta--helpoutput (e.g.install, i, add)Consolidates work from #155, #170, and #224 — all three original authors are credited.
Lazy loading
Alias resolution is designed to minimize unnecessary subcommand loading:
name in subCommandsis a plain property check — no subcommand is resolved or imported.() => import("./cmd.ts")) are only triggered as needed.Hoisting aliases into a separate top-level map was considered but rejected to keep the DX simple (single source of truth in
meta).Test plan
i→install)add→install)ws ls→workspace list)E_UNKNOWN_COMMAND🤖 Generated with Claude Code
Co-Authored-By: 苏向夜 67710306+fu050409@users.noreply.github.com
Co-Authored-By: Horu HigherOrderLogic@users.noreply.github.com
Co-Authored-By: TJ ratiofu@users.noreply.github.com