Skip to content

feat: add natural CLI command aliases - #19

Merged
bmdavis419 merged 1 commit into
mainfrom
feat/command-aliases
Jul 9, 2026
Merged

feat: add natural CLI command aliases#19
bmdavis419 merged 1 commit into
mainfrom
feat/command-aliases

Conversation

@bmdavis419

@bmdavis419 bmdavis419 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add familiar aliases for tx9 lifecycle, archive, and update commands
  • generate dispatch and help aliases from one ordered command specification
  • reserve command aliases as box names to prevent inaccessible boxes

Validation

  • go vet -buildvcs=false ./...
  • go test -buildvcs=false ./...
  • make syntax lint test
  • git diff --check

Review

  • independent correctness review completed; alias/name collision fix applied and re-reviewed
  • independent CLI UX/documentation review completed with no findings

Open in Devin Review

Note

Add natural language aliases for CLI commands in tx9

  • Adds aliases such as new, ls, ssh, shell, export, save, load, restore, update, rm, and remove to the CLI dispatcher in dispatch.go, backed by a new commandSpec struct as a single source of truth for commands and aliases.
  • Updates help output to include an "Aliases" section derived from commandSpecs, and changes printUsage to accept io.Writer instead of *os.File.
  • Adds the new alias names to the reserved names list in names.go so user-supplied box names cannot collide with CLI vocabulary.
  • Updates the public site to mention that tx9 update is an alias for tx9 upgrade.

Macroscope summarized c1f5df9.

Greptile Summary

This PR adds natural aliases for existing tx9 CLI commands. The main changes are:

  • A single ordered command spec now drives dispatch, alias mapping, and help output.
  • New aliases include new, ls, shell, save, load, restore, update, rm, and remove.
  • Alias names are reserved as invalid box names to avoid command/name collisions.
  • CLI design docs and the public site copy were updated for the new aliases.

Confidence Score: 5/5

Safe to merge with minimal risk.

The dispatcher keeps canonical command behavior intact while deriving aliases and usage output from one source of truth. Name validation blocks the newly introduced aliases. Tests cover alias registration, help output, and reserved names.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The Go vet step was executed from /home/user/repo using go vet -buildvcs=false ./..., and exited with code 0.
  • The Go test step was executed from /home/user/repo using go test -buildvcs=false ./..., and all package tests passed or no tests were found, with exit code 0.
  • A git diff check was run from /home/user/repo using git diff --check, and it exited 0.
  • The environment checked for shellcheck with command -v shellcheck, which exited 1 (not found).
  • The make syntax lint test attempted to run and failed because shellcheck was not available, exiting with code 2 and reporting that shellcheck is required for make check.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
internal/cli/dispatch.go Replaces separate command/help/alias maps with ordered command specs that drive dispatch and help output; no issues found.
internal/cli/dispatch_test.go Adds tests confirming aliases target registered commands and appear in usage output; no issues found.
internal/names/names.go Reserves new command aliases as invalid box names to avoid CLI vocabulary collisions; no issues found.
internal/names/names_test.go Expands name validation tests for the newly reserved aliases; no issues found.
docs/tx9-cli-design.md Updates the command surface documentation to include the new natural aliases; no issues found.
site/public/index.html Updates public CLI usage copy to mention the update alias; no issues found.

Reviews (1): Last reviewed commit: "feat: add natural CLI command aliases" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors CLI command registration in internal/cli/dispatch.go to use a unified commandSpecs model, expanding recognized aliases (e.g. new, ls, ssh/shell, export/save, load/restore, update, rm/remove). Reserved names, tests, docs, and the landing page are updated to match.

Changes

CLI Alias Expansion

Layer / File(s) Summary
Command spec model and alias registration
internal/cli/dispatch.go
Replaces static commandOrder/commandHelp/manual alias maps with a commandSpec/commandSpecs model driving both command registration and alias derivation; printUsage switches to io.Writer and renders from commandSpecs.
Alias registration and usage tests
internal/cli/dispatch_test.go
New tests validate that the aliases map matches expected mappings and that rendered usage output lists each alias.
Reserved names update and validation tests
internal/names/names.go, internal/names/names_test.go
New alias words are added to the reserved map, and TestValidate is extended with cases confirming these words are rejected.
Design doc and landing page alias documentation
docs/tx9-cli-design.md, site/public/index.html
The CLI design doc's Decision #4 text and command surface table are updated to reflect expanded aliases; the landing page documents tx9 update as an alias for tx9 upgrade.

Possibly related PRs

  • davis7dotsh/tx9#16: Also modifies internal/cli/dispatch.go around the enter/ssh command help and alias handling, overlapping with the same dispatch registration code paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: adding natural CLI command aliases.
Description check ✅ Passed The description matches the PR changes by summarizing aliases, dispatch/help refactor, reserved names, and validation steps.

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/cli/dispatch.go (1)

28-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Clean single-source-of-truth refactor. Deriving commands/aliases from one ordered commandSpecs slice removes the drift risk between dispatch and help that existed with the old separate tables.

One forward-looking gap: there's no guard preventing an alias from colliding with a canonical command name or with the reserved words handled in the Run() switch (help, version, -h, etc.). The PR description notes an alias/name collision bug was already found and fixed once during review — a small init-time check would catch a repeat of that class of bug automatically as more aliases get added later.

♻️ Optional collision guard
 func registerCommands() {
 	for _, spec := range commandSpecs {
+		if _, exists := commands[spec.name]; exists {
+			panic(fmt.Sprintf("tx9: duplicate command name %q", spec.name))
+		}
 		commands[spec.name] = spec.run
 		for _, alias := range spec.aliases {
+			if _, exists := commands[alias]; exists {
+				panic(fmt.Sprintf("tx9: alias %q collides with command name", alias))
+			}
+			if _, exists := aliases[alias]; exists {
+				panic(fmt.Sprintf("tx9: duplicate alias %q", alias))
+			}
 			aliases[alias] = spec.name
 		}
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/dispatch.go` around lines 28 - 64, The new command registry in
registerCommands() should also validate that aliases do not collide with
canonical command names or the reserved Run() switch words like help, version,
and -h. Add an init-time guard around commandSpecs processing in
internal/cli/dispatch.go that checks each spec.name and alias before populating
commands and aliases, and fail fast if any conflict is found so future additions
cannot reintroduce alias/name collisions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/cli/dispatch.go`:
- Around line 28-64: The new command registry in registerCommands() should also
validate that aliases do not collide with canonical command names or the
reserved Run() switch words like help, version, and -h. Add an init-time guard
around commandSpecs processing in internal/cli/dispatch.go that checks each
spec.name and alias before populating commands and aliases, and fail fast if any
conflict is found so future additions cannot reintroduce alias/name collisions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b4c16e0-01c1-4b95-a8ec-b521be9a963e

📥 Commits

Reviewing files that changed from the base of the PR and between c215c75 and c1f5df9.

📒 Files selected for processing (6)
  • docs/tx9-cli-design.md
  • internal/cli/dispatch.go
  • internal/cli/dispatch_test.go
  • internal/names/names.go
  • internal/names/names_test.go
  • site/public/index.html

@bmdavis419
bmdavis419 merged commit 65c9ada into main Jul 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant