Skip to content

feat(cli): move version to a subcommand and make -v verbosity - #120

Merged
jmgilman merged 1 commit into
masterfrom
feat/cli-ux-p1-version-flags
Jun 8, 2026
Merged

jmgilman merged 1 commit into
masterfrom
feat/cli-ux-p1-version-flags

Conversation

@jmgilman

@jmgilman jmgilman commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

P1 / PR-1.2 of the CLI UX overhaul. Frees -v for verbosity and lands the global UX flag surface + verbose logging on slog.

⚠️ Breaking changes (pre-1.0, intentional — locked decisions #1 & #3)

  • yacd --version is removed. Cobra's Version: field and the --version flag are dropped; use yacd version (prints the same build-metadata line to stdout).
  • -v/--verbose is always verbosity (a count: -v, -vv, -vvv), never version.
  • -q/--quiet forces the logger off (overriding -v/--log-level); data and the final returned error reason still print.

What's here

  • Drop Version:/SetVersionTemplate; add version.go (yacd version → stdout).
  • Add persistent flags --verbose -v (count), --quiet -q, --non-interactive, --color, --no-color. This PR consumes only -v and -q; --non-interactive/--color/--no-color are registered for the foundation and wired into ui.IO in PR-1.4 (adding their consumer — resolveUX — now would be dead code that fails the unused linter).
  • PersistentPreRunE reads -v/-q directly off cmd.Flags() (flag-only, env-immune) without changing loadRuntimeConfig's signature (that change is coupled to deleting the 11 re-call sites and lands atomically in PR-1.4). It raises the resolved --log-level by the verbose count via raise() and forces the logger off under -q.
  • raise(base, count): additive along error<warn<info<debug, capped at debug, never lowers; newLogger gains a quiet param returning slog.DiscardHandler.
  • Added build BuildInfo to commandContext so version (and tests) read it symmetrically.

Note on raise() semantics

The 063 design prose is internally inconsistent: §6 describes additive warn→info→debug stepping, but one example claims YACD_LOG_LEVEL=warn … -v → debug. Additive-by-one is the only model that delivers goal 5's graduated -vvv control and matches the stepping description, so I implemented that: raise("warn",1)=="info", raise("info",1)=="debug". (Flagging for visibility; -v from the default info base still reaches debug as expected.)

Testing

  • gofmt/go vet/go build clean; moon run root:check (golangci-lint + generated-drift) green; moon run root:test (full envtest gate) green; git diff --check clean.
  • New/changed tests: version subcommand prints to stdout (byte-identical to the old --version); --version is now an unknown flag; version still prints under -q (data survives the mute); -vvv version is accepted (verbosity, not version); raise() table (env-base steps, cap, never-lowers, unknown/negative); newLogger discard-under-quiet + level gating.

Part of the P1 foundation series (1.1 #119 merged → 1.2 → … → 1.6).

🤖 Generated with Claude Code

P1 foundation (PR-1.2) of the CLI UX overhaul. Drop cobra's Version: field and
the --version flag so -v is free, and add a `yacd version` subcommand that
prints the same build-metadata line to stdout. Add the persistent UX flags
--verbose/-v (count), --quiet/-q, --non-interactive, --color, and --no-color;
this PR consumes only -v and -q (the rest are registered for the foundation and
wired to ui.IO in a later phase).

Verbose logging now runs on slog: PersistentPreRunE reads -v/-q directly off
cmd.Flags() (flag-only, env-immune) without changing loadRuntimeConfig's
signature, raises the resolved --log-level by the verbose count via raise()
(additive along error<warn<info<debug, capped, never lowering), and forces the
logger off under -q while the final returned error still prints via the exit
handler.

Note on raise() semantics: the design prose is internally inconsistent (it both
describes additive "warn->info->debug" stepping and gives a warn+-v=>debug
example). Additive-by-one is the only model that delivers goal 5's graduated
-vvv control and matches the stepping description, so raise("warn",1)=="info".

BREAKING (pre-1.0, intentional): `yacd --version` is removed; use `yacd version`.
-v/--verbose is always verbosity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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