feat(cli): add short aliases to every resource command - #52
Open
mateuscardosodeveloper wants to merge 12 commits into
Open
mateuscardosodeveloper wants to merge 12 commits into
mateuscardosodeveloper wants to merge 12 commits into
Conversation
Seven aliases on a scheme shared by every family: a prefix plus a two or three character verb. `act-ls`, `act-nf`, `act-crt`, `act-ed`, `act-on`, `act-off`, `act-dlt`. The prefix is `act-`, not `ac-`, because the bare `ac` is analysis-console in the published package. An `ac-*` family would put two resources under one prefix. `act-on` / `act-off` rather than shortening enable/disable: a two-letter difference between a harmless flag and its opposite is the kind of pair that gets typed wrong.
`dc-ls`, `dc-nf`, `dc-crt`, `dc-ed`, `dc-lng`, `dc-dlt`. Replaces `dl-list`, which was one character away from `dl` (device-list) while pointing at an unrelated resource.
`se-ls`, `se-nf`, `se-crt`, `se-ed`, `se-dlt`. Replaces `sl`.
`ru-ls`, `ru-nf`, `ru-crt`, `ru-ed`, `ru-dlt`. Replaces `rul`. `run-user-` is the longest prefix in the CLI, so these save the most: nine characters on `run-user-create`.
`an-ls`, `an-nf`, `an-crt`, `an-ed`, `an-dlt`. The six older commands in this namespace keep their published word aliases: deploy, run, at, ac, ad, am. Renaming any of those would break callers on npm. Also drops the comment saying analysis-list could not have an alias because `al`, `am`, `at`, `ac` and `ad` were taken. The prefixed scheme is what resolves it, so the comment now records the reasoning instead of the refusal.
`am-ls`, `am-nf`, `am-crt`, `am-ed`, `am-dlt`, replacing `am-list`, `am-info`, `am-create`, `am-edit` and `am-delete`. Those five were the first prefixed aliases in the CLI and set the pattern this scheme follows; only the verb half changes. The help examples move with them, since an example naming an alias that no longer resolves is worse than no example.
`sq-ls`, `sq-nf`, `sq-crt`, `sq-ed`, `sq-run`, `sq-dlt`, `sq-tbl`, `sq-rev`. Replaces `sql-ls` and `sql-run`, which shared the command's own `sql-` prefix and so saved almost nothing — `sql-v` against `sql-version` is one keystroke. Moving the family to `sq-` gives it one convention instead of two, and the help examples follow.
`dv-crt`, `dv-ed`, `dv-dlt`, `dv-tkn`, `dv-prm`, `dv-tp`, `dv-cp`. The five published aliases in this namespace are untouched: dl, info, inspect, bkp, nc. `dv-` rather than `de-` or `dc-`: dictionaries already holds `dc-`, and `dl` shows how fast a single letter after `d` stops being readable.
`en-ls`, `en-nf`, `en-crt`, `en-ed`, `en-dlt`, `en-dt`, `en-sch`, `en-cp`. First aliases this family has had.
`fl-ls`, `fl-up`, `fl-dl`, `fl-url`, `fl-mv`, `fl-rn`, `fl-cp`, `fl-dlt`, `fl-prm`. First aliases this family has had. Two suffixes look like collisions and are not: `fl-dl` is a different string from `dl` (device-list), and `fl-prm` shares its suffix with `dv-prm` (device-param) only across families, never within one.
Commander throws at registration on a duplicate — an alias colliding with another alias or with a command name — which takes the whole CLI down at startup rather than failing just the new command. The `al` and `am` near misses were caught only because the man test happens to build the tree. This makes the check explicit, asserting on the built program rather than on the generated roff: the man page never records aliases, so the two assertions in generate-man.test.ts match help example text and would stay green if an alias were deleted. Their comments now say so, and point here. The walk recurses, because `backup` nests four subcommands. Collisions are per-scope: commander resolves a token against the containing command's own list, so `backup create` and a top-level `create` could coexist. A flat scan would both miss a collision under `backup` and invent ones that cannot happen. Proven by removing an alias and by adding an undeclared nested one — the first fails naming the command, the second fails the table check. The snapshot moves with the renamed aliases in the access-management and sql help examples: fourteen lines, all of them example text.
The table listed roughly twenty commands out of eighty-nine, missing actions, dictionaries, secrets, run-users, access-management, sql, entities and files entirely — it was already stale before this branch. Rebuilt from the command tree, keeping the existing shape: `alias, command` terms, bold section headings, and the nested backup subcommands. Nothing reads this file in CI, but with seventy-seven aliases it is the only complete inventory outside `--help`, which shows just the first alias per command.
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
Gives every resource command a short alias on one scheme: a family prefix plus a two or three character verb. 77 aliases across 10 families, saving about seven characters per command.
act-act-ls,act-on,act-offdc-dc-ls,dc-lngse-se-ls,se-nfru-ru-ls,ru-crtan-an-ls,an-dltam-am-ls,am-crtsq-sq-ls,sq-tbl,sq-revdv-dv-crt,dv-tknen-en-ls,en-dt,en-schfl-fl-ls,fl-prm,fl-dlVerbs:
lsnfcrteddltcpdtschonofflngtblrevruntknprmtpupdlurlmvrn.Why
Reviewing the stacked series, the tech lead noticed the new commands had no aliases while shipped ones did (
device-listhasdl). Only 11 of the 41 new commands carried one, and the gap was uneven inside the series itself: access-management aliased all five of its commands, analysis CRUD aliased none.entity-*andfiles-*predate the series and had never had an alias, so they are included rather than left as a second gap.Naming decisions that took a call:
act-for actions, notac-. The bareacisanalysis-consolein the published package, so anac-*family would put actions and analysis under one prefix. Costs one character on seven aliases.act-on/act-offinstead of shortening enable and disable. An earlier draft hadadisandadel, two characters apart, one reversible and one not.sq-for TagoSQL, replacingsql-lsandsql-run. Reusing the command's ownsql-prefix saved almost nothing:sql-vagainstsql-versionis one keystroke. The family now has one convention.fl-dlis a different string fromdl(device-list), andfl-prmshares its suffix withdv-prmonly across families, never within one.Not aliased:
init,login,set-env,list-env,whoami,data,copy-tab,backup, and the fourbackupsubcommands. They run 4 to 8 characters against a 12.5 average for the aliased set, and several already are the short form.datais the shorthand for device data.Test plan
npx vitest run: 1754 tests passing, 166 filesnpx tsc --noEmitclean,npm run linterclean,npx oxfmtno rewritesnpm run buildpassessrc/lib/alias-registry.test.ts: 80 tests covering no duplicate token per scope, no alias shadowing a command name, and every expected pair registeredbackup list(fails the table check). The non-recursive first version passed that second caseac ad am at bkp deploy dl export info inspect nc rununknown commanden-dt,fl-prm,sq-rev,act-offbackupsubcommands (178 tokens, 101 names, 77 aliases, 0 duplicates in any category), straight from the source files (77 aliases, no overlap with command names), and the CLI booting, since commander throws at registration on any duplicateEXPECTED_ALIASESmatches the tree exactly: 77 declared, 77 registered, no difference in either directionBreaking changes
Eleven aliases are renamed:
al,sl,rul,dl-list,sql-ls,sql-run, and the fiveam-*forms.Every one exists only in this stack's open PRs. Checked
masterdirectly: none has been released, so no caller on npm can depend on them. The 12 aliases that do ship in 3.3.0 are untouched.Keeping the old names would have shipped two competing formats, which is the inconsistency this PR exists to remove.
Risk (CIA)
Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low
Additive alias registration plus 11 renames confined to unreleased branches. A duplicate cannot ship silently: commander throws at registration, so a collision fails the suite and the build. No command name, option, or handler changes.
Related
The README command table is rebuilt here as well. It listed roughly 20 of 89 commands, missing actions, dictionaries, secrets, run-users, access-management, sql, entities, and files entirely, so it was stale before this branch. Regenerated from the command tree in the existing shape.
That matters more than it looks:
--helpshows only the first alias per command (configure-help.tscallshelp.alias(), singular), the man page records none, and there is no shell completion. The README table is the only complete inventory.An independent design review argued for about 9 aliases instead of 77, on the grounds that the savings are thin and a uniform alias removes the signal
alused to carry next to a bareaction-info. The uniform scheme was chosen because consistency was the ask, and the short-verb format answers the strongest half of that objection: seven characters saved rather than the three the first draft managed. Recorded so the trade-off stays reversible.Base is
feat/tagosql-commands(#49). Merge that one first.