Skip to content

fix: keep known initialisms together in generated command names - #60

Merged
ctreatma merged 3 commits into
mainfrom
fix/initialism-kebab-case
Aug 21, 2026
Merged

fix: keep known initialisms together in generated command names#60
ctreatma merged 3 commits into
mainfrom
fix/initialism-kebab-case

Conversation

@displague

@displague displague commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Generated CLI command/flag names split every uppercase letter onto its own word, so initialism-heavy identifiers came out as b-g-p, s-s-h-key, i-p-address, v-l-a-ns, o-auth2-token, etc.
  • Added internal/casing.CamelToKebab, which recognizes a small list of known initialisms (BGP, SSH, IP, API, VLAN, VRF, CSP, VC, EIA, GET/POST/etc., UUID, ID, ...), normalizes the irregular OAuth casing, and keeps version-style digit suffixes (OAuth2, IPv4, IPv6) attached to their word instead of splitting them off.
  • Replaced the 6 duplicated, buggy camelToKebab implementations in internal/register/register.go and internal/parser/extractor.go with calls to the shared helper.
  • Regenerated docs/ via make docs so the generated docs match the renamed commands (CI checks this with make docs-check).

Before → after (discovered via git grep -E '[a-z]-[a-z]-[a-z]'):

  • b-g-pbgp, b-g-p-sessionbgp-session
  • s-s-h-keyssh-key, find-s-s-h-keysfind-ssh-keys
  • i-p-addressip-address, v-l-a-nsvlans, v-r-fsvrfs
  • create-a-p-i-keycreate-api-key
  • get-o-authget-oauth, o-auth2-tokenoauth2-token
  • vlan-c-s-p-connectionvlan-csp-connection
  • vrf-b-g-p-neighborsvrf-bgp-neighbors

Legitimate single-letter hyphenated terms like a-side/z-side are unaffected.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (added internal/casing/casing_test.go)
  • make docs and committed the regenerated files so make docs-check passes in CI
  • Built the CLI and manually verified metalv1 bgp, metalv1 ip-addresses, metalv1 ssh-keys, metalv1 vlans, metalv1 vrfs, and accesstokenv1 oauth2-token commands

The camelToKebab conversion used for CLI command/flag names inserted a
dash before every uppercase letter, splitting initialisms like BGP,
SSH, IP, VLAN, and API into commands such as b-g-p, s-s-h-key, and
i-p-address. Add a shared internal/casing package that recognizes a
list of known initialisms and keeps them as a single word, fixing
commands like bgp, ssh-key, ip-address, and oauth.
Digits like the "2" in OAuth2 or the "4"/"6" in IPv4/IPv6 were treated
as a new word boundary, producing oauth-2-token instead of the
well-known spec name oauth2-token. Trailing digits now attach to the
preceding word like other suffixes.
Run 'make docs' to pick up the renamed commands (e.g. b-g-p -> bgp,
create-a-p-i-key -> create-api-key, o-auth2-token -> oauth2-token)
from the camelToKebab fix.
@displague

Copy link
Copy Markdown
Member Author

As a backwards compatibility bridge, we could consider matching action names regardless of hyphens.

@displague

displague commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

I'm tempted to remove "-api" from action and service names as this is another trait of the published API specs whose faithful representeation detracts from CLI UX.

I'm also considering adding logical service names that would proxy and aggregate for actions among existing service names. The actual service names could then be aliased, hidden, or dropped.

The Docs site does similar:

For the CLI, the wrapper name would not have nested service names. The operations across the various services would be made available under the wrapper service name. Conflicts would need to be flagged on build.

@ctreatma

Copy link
Copy Markdown
Contributor

As a backwards compatibility bridge, we could consider matching action names regardless of hyphens.

This is v0, so I think it's reasonable to break the old, poorly-named commands and preferable not to add that complexity (it will never get cleaned up once it's in there).

I'm tempted to remove "-api" from action and service names as this is another trait of the published API specs whose faithful representeation detracts from CLI UX.

Reasonable but I'm not clear if this is something we could get by making changes somewhere upstream (catalog, SDK, somewhere else) that would provide broader benefit.

I'm also considering adding logical service names that would proxy and aggregate for actions among existing service names. The actual service names could then be aliased, hidden, or dropped.

This definitely seems like something we should drive from the catalog rather than here.

@ctreatma
ctreatma merged commit 113c4e4 into main Aug 21, 2026
5 checks passed
@ctreatma
ctreatma deleted the fix/initialism-kebab-case branch August 21, 2026 16:10
@github-actions

Copy link
Copy Markdown

This PR is included in version 0.4.1 🎉

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.

2 participants