Skip to content

test(cmd): enforce cross-product CLI conventions - #33

Merged
vks-team merged 1 commit into
mainfrom
feat/conventions-test
Jul 7, 2026
Merged

test(cmd): enforce cross-product CLI conventions#33
vks-team merged 1 commit into
mainfrom
feat/conventions-test

Conversation

@vks-team

@vks-team vks-team commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Item #2 of the CLI-flow alignment: convention-as-tests (mirrors the mcp test_conventions.py). A repo-wide Go test walks the assembled command tree (rootCmd) and enforces uniform rules so new product commands stay consistent without relying on reviewers to remember them:

  1. Destructive safety — commands whose verb is delete/stop/reboot must define --dry-run and --force.
  2. Canonical verbs — a denylist rejects non-canonical synonyms (remove/rm/destroy→delete, fetch/describe/show→get, ls→list, add/new→create, modify/edit→update). grn configure subcommands (local-file verbs set/get/list) are exempt.
  3. Help present — every leaf command has a Short.

Why a denylist instead of a strict verb-noun allowlist

The CLI's naming is intentionally heterogeneous (vks create-nodegroup, wait cluster-active, vserver server create), so a rigid "verb-noun allowlist" would either break existing commands or need many exemptions. A denylist + the destructive-safety rule capture the high-value, uniform invariants and pass cleanly on all current commands — while still catching real drift (typos / wrong synonyms) in new commands.

Verified

All current commands already conform: go test ./cmd/ green (3 new tests pass), full go test ./... green, go vet clean. The scaffold's generated list-examples command also conforms.

Plan progress

Test-only; no change to the shipped grn binary.

Add a repo-wide conventions test that walks the assembled command tree and
gates new commands so product teams stay consistent without reviewer memory:
- destructive commands (delete/stop/reboot) must define --dry-run and --force;
- command verbs must be canonical (denylist rejects remove/fetch/ls/add/etc.);
- every command has a Short description.
All current commands already conform; the test is a gate for future ones.
@vks-team
vks-team merged commit d2716f1 into main Jul 7, 2026
4 checks passed
@vks-team
vks-team deleted the feat/conventions-test branch July 25, 2026 15:10
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