Correct the Vaultik.UI doc comment about --cron (closes #84) #86
Reference in New Issue
Block a user
Delete Branch "fix-ui-cron-comment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the false
Vaultik.UIdoc comment described in #84. Comments anddocumentation only — the Go diff contains no non-comment lines.
What the code actually does
I verified the description against the code rather than taking the issue on
faith, and the issue is correct:
internal/vaultik/vaultik.go:109constructs the field once asui.New(os.Stdout). Nothing reassignsv.UIanywhere outsideNew, so nowriter is ever swapped in.
internal/cli/app.go:58-60(setupGlobals) callsv.UI.SetQuiet(true)when
opts.Cron || opts.Quiet.internal/ui/ui.go, thequietflag is checked by exactly sevenmethods —
Beginf,Completef,Infof,Noticef,Detailf,Progressf,Bannerf— which return early.Warningf(line 158) andErrorf(line 167)have no quiet check at all and always write to
w.out.So
--cron(and--quiet, which takes the same branch) suppressesinformational output only; Warning and Error still reach the user. The one
io.DiscardUI writer in the tree isinternal/snapshot/scanner.go:176, anil-UI fallback for the scanner, unrelated to
--cron— plausibly where the"discarding writer" wording came from.
No behavior change was needed: the code already matches a coherent
description, it was only the comment that lied.
Before
After
Other locations (DoD item 2)
I grepped every
--cron/ quiet mention in the tree.Corrected:
README.mdline 171 described--cronas "Silent unless error", whichunderstates what survives — warnings are emitted too, and the codebase
deliberately relies on that (
internal/vaultik/snapshot.go:116-124routesthe end-of-run summary through
UI.Warningfprecisely so cron deliverssomething). Now reads "Silent on total success; warnings and errors are
still printed (for crontab)".
Audited and already accurate, left untouched:
internal/log/log.go:53-55— states the cron/quiet log level keeps warningsand errors visible, which matches
level = slog.LevelWarn.internal/cli/snapshot.go:104— "--cron suppression is wired through v.UIby setupGlobals"; true, and it does not claim total silence.
internal/vaultik/snapshot.go:116-120— correctly states Complete is droppedwhile the warning summary still fires.
Reported, not changed
The
--croncobra flag help string atinternal/cli/snapshot.go:138reads"Run in cron mode (silent unless error)", carrying the same imprecision the
README line had. That string is program output rather than a comment, so
changing it under a docs-only issue would be a behavior change; leaving it for
separate triage.
Also noted for separate triage:
make lintnow printsThe linter 'gomodguard' is deprecated (since v2.12.0) ... Replaced by gomodguard_v2on every run. It does not fail the gate, and.golangci.ymlishash-pinned, so it is out of scope here.
Verification
script/cibuild— literalEXIT=0, captured immediately after the run.The run was forced uncached rather than trusted: the new commit invalidates the
Docker source-copy layer, so
#19 [lint 8/8] RUN make lintexecuted in 72.0sand printed
0 issues., and#31 [builder 8/9] RUN make testexecuted in100.0s. Neither was
CACHED— the onlyCACHEDlayers in the build wereapk add,COPY go.mod go.sum, andgo mod download. Every package line inthe test stage shows a real duration with no
(cached)marker.Separately,
GOFLAGS=-count=1 make checkwas run in the worktree to defeat theGo test cache independently of Docker:
0 issues.from lint, and all 14 testpackages
okwith real timings and no(cached)entries.Diff scope confirmed mechanically: filtering the Go portion of the diff for
added/removed lines that are not comment lines yields zero lines.
.golangci.ymlis untouched and still hashes to021cc83f4e6fc7c31b95b34b846723dfcf20b66b7baeea1dc40406e643346bcb.The field comment claimed the cli layer replaces the UI writer with a discarding writer in --cron mode. It does not: the writer is created once as ui.New(os.Stdout) and never reassigned, and setupGlobals calls UI.SetQuiet(true) instead. Quiet mode drops Begin, Complete, Info, Notice, Detail, Progress, and Banner, but Warningf and Errorf have no quiet check and always emit, so --cron does not make the writer silent. The README's --cron bullet had the adjacent understatement ("Silent unless error"), and now names warnings as well. Comments and documentation only; no behavior change.Summary of what landed here, in commit
dcf3dd3:internal/vaultik/vaultik.go— theVaultik.UIfield comment now namesUI.SetQuiet(true)as the actual mechanism, lists the seven message classes it drops, and states that Warning and Error are still emitted under--cron. It also notes that--quiettakes the same branch and that the writer is never swapped out.README.md— the--cronbullet no longer says "Silent unless error"; it now says silent on total success, with warnings and errors still printed.TODO.md— Completed Steps entry in the same commit as the work.Verification, forced uncached because a cached gate proves nothing here:
script/cibuildreturned literalEXIT=0. The new commit invalidated the Docker source layer, so#19 [lint 8/8] RUN make lintran for 72.0s and printed0 issues., and#31 [builder 8/9] RUN make testran for 100.0s. Neither stage wasCACHED; the onlyCACHEDlayers wereapk add,COPY go.mod go.sum, andgo mod download. No test package line carried a(cached)marker.GOFLAGS=-count=1 make checkin the worktree:0 issues.from lint and all 14 test packagesokwith real durations, none cached.Scope check: filtering the Go half of the diff for added/removed lines that are not comment lines returns zero lines, so there is no behavior change.
.golangci.ymluntouched and still at the pinned sha256.