From 20a0cd0f48c362ed630c69259facf177533ebfee Mon Sep 17 00:00:00 2001 From: James Maes Date: Tue, 9 Jun 2026 08:00:09 -0500 Subject: [PATCH] fix(#34): remove the no-op --quiet/--verbose flags The persistent --quiet/-q and --verbose/-v flags were bound on the root flag set but read nowhere -- pure no-op flags advertising behavior they never delivered. Decision: REMOVE (Option B), not WIRE. A review of every output site showed there is no non-essential, human-facing output to gate behind --quiet (the only stdout output is the machine report from audit/check/ apply and essential confirmations like "wrote X"), and no diagnostic or tracing facility for --verbose to enable (the model's ResolveOptions. Verbose field is itself dead -- no resolver reads it, nothing writes diagnostics). Wiring would have required inventing new output purely to justify the flags, i.e. hollow/cosmetic wiring. Removing the no-ops is the honest, lower-risk choice for pre-1.0 (v0.3.0). Passing --quiet/-q/--verbose/-v now yields an unknown-flag usage error (exit 2). Updated TestNewRootCmd and added TestQuietVerboseFlagsRemoved; updated README, the design doc, and the CHANGELOG. The optional LOW item (typed-sentinel refactor of isWriteRefusal) is deferred: the refusal strings span both internal/applier and internal/config, so a sentinel refactor would touch the applier write/refusal path that issue #33 is changing on a separate branch, risking merge conflicts and cross-package sprawl. Kept this change scoped to the CLI flag surface. Closes #34 --- CHANGELOG.md | 3 +++ README.md | 2 -- cmd/license-tool/commands.go | 4 ---- cmd/license-tool/commands_test.go | 21 ++++++++++++++++++++- docs/license-tool-design.md | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dff4fe0..f52dde5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed +- Removed the no-op `--quiet`/`-q` and `--verbose`/`-v` persistent flags. They were bound but never read, so they advertised behavior they never delivered; the CLI has no non-essential output to suppress and no diagnostic stream to emit. Passing them now produces a usage error (exit 2). + ## [0.3.0] - 2026-06-04 ### Install diff --git a/README.md b/README.md index c02d534..72fe4df 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,6 @@ overwrite it unless `--force` is passed. --include restrict to matching paths (repeatable) --exclude skip matching paths (repeatable) --no-gitignore do not honor .gitignore during enumeration ---quiet, -q suppress non-essential output ---verbose, -v verbose output ``` ### Exit codes diff --git a/cmd/license-tool/commands.go b/cmd/license-tool/commands.go index fab3ad0..3b84237 100644 --- a/cmd/license-tool/commands.go +++ b/cmd/license-tool/commands.go @@ -30,8 +30,6 @@ type sharedFlags struct { include []string exclude []string noGitignore bool - quiet bool - verbose bool } // newRootCmd assembles the full command tree. WHY a constructor that takes @@ -53,8 +51,6 @@ func newRootCmd(info buildInfo) *cobra.Command { pf.StringArrayVar(&shared.include, "include", nil, "glob of files to include (repeatable)") pf.StringArrayVar(&shared.exclude, "exclude", nil, "glob of files to exclude (repeatable)") pf.BoolVar(&shared.noGitignore, "no-gitignore", false, "do not inherit .gitignore on the non-git walk") - pf.BoolVarP(&shared.quiet, "quiet", "q", false, "suppress non-essential output") - pf.BoolVarP(&shared.verbose, "verbose", "v", false, "verbose diagnostic output") root.AddCommand( newAuditCmd(shared), diff --git a/cmd/license-tool/commands_test.go b/cmd/license-tool/commands_test.go index 5b602c2..bb5d4fd 100644 --- a/cmd/license-tool/commands_test.go +++ b/cmd/license-tool/commands_test.go @@ -159,9 +159,28 @@ func TestNewRootCmd(t *testing.T) { } // Persistent flags are bound on the root. - for _, f := range []string{"config", "include", "exclude", "no-gitignore", "quiet", "verbose"} { + for _, f := range []string{"config", "include", "exclude", "no-gitignore"} { assert.NotNil(t, root.PersistentFlags().Lookup(f), "persistent flag %q", f) } + + // The no-op --quiet/--verbose flags (and their -q/-v shorthands) were removed + // in #34: the CLI had no non-essential output to gate and no diagnostic stream + // to emit, so the flags advertised behavior they never delivered. + for _, f := range []string{"quiet", "verbose"} { + assert.Nil(t, root.PersistentFlags().Lookup(f), "removed persistent flag %q must not be registered", f) + } +} + +func TestQuietVerboseFlagsRemoved(t *testing.T) { + isolateEnv(t) + dir := fixtureDir(t) + for _, arg := range []string{"--quiet", "-q", "--verbose", "-v"} { + t.Run(arg, func(t *testing.T) { + _, stderr, code := executeRoot(t, "audit", arg, dir) + assert.Equal(t, exitUsage, code, "removed flag %q should yield a usage error", arg) + assert.Contains(t, stderr, "unknown") + }) + } } func TestArgPath(t *testing.T) { diff --git a/docs/license-tool-design.md b/docs/license-tool-design.md index c2ecfae..f573a7b 100644 --- a/docs/license-tool-design.md +++ b/docs/license-tool-design.md @@ -20,7 +20,7 @@ license-tool init [path] # Scaffold a .license-tool.yaml (interactive on a license-tool version # Version, commit, build date ``` -Shared flags: `--config `, `--include ` (repeatable), `--exclude ` (repeatable), `--no-gitignore`, `--quiet|-q`, `--verbose|-v`. +Shared flags: `--config `, `--include ` (repeatable), `--exclude ` (repeatable), `--no-gitignore`. `audit` / `check` flags: `--format text|json|markdown` (default `text`; `check` forces machine-friendly), `--output `, `--deps|--no-deps` (default on), `--resolve-deps ondisk|tool|off` (default `ondisk`), `--fail-on ` (check only; default `missing-header,unknown-license,policy-violation`). -- 2.54.0