Route direct-stdout command output through internal/ui (closes #149)
check / check (pull_request) Successful in 1m45s

version, info, remote info, config, and database delete wrote plain text
straight to stdout, so they were unstyled and ignored --quiet. Output now
falls in two buckets, both governed by internal/ui.

Status lines and confirmations (config init, config set, database
delete) go through the ui message methods: styled, and --quiet silences
them. The data a command exists to produce is written plain, since a
marker would corrupt a table or a parsed document: the version, info, and
remote info reports, the snapshot list table, config get values, and the
--json documents. --quiet silences the human reports and tables but never
the config get value or the --json documents, which a script depends on.
The database delete confirmation prompt is always shown; it is an
interactive exchange the operator must see.

The pure-cli commands reach internal/ui through a small commandUI helper
that builds a ui.Writer on the command's stdout in quiet mode when
--quiet is set. NewForTesting now supplies a UI writer so the quiet gate
is never nil. The README output-style section states the resulting rule.

Model: opus-4-8
This commit is contained in:
2026-09-22 18:03:45 +00:00
parent dd7a610c23
commit b4a539c8f9
14 changed files with 427 additions and 66 deletions
+20 -11
View File
@@ -645,17 +645,26 @@ priority.
## output style
The operational narration of the long-running commands — the Begin,
Complete, Progress, and status lines of `snapshot create`, `prune`,
`snapshot restore`, and the like — goes through helpers in `internal/ui`
and conforms to the uniform style below. Some commands instead write
plain text straight to stdout (`version`, `info`, `config`, the
`database delete` prompt, and the `snapshot list` table); that output is
unstyled and does not honor `--quiet`. Routing it through `internal/ui`
is tracked in
[issue #149](https://git.eeqj.de/sneak/vaultik/issues/149). Color is
enabled when stdout is a TTY and the `NO_COLOR` environment variable is
unset (https://no-color.org/).
Every command's user-facing output is governed by `internal/ui`, in one
of two ways. Color is enabled when stdout is a TTY and the `NO_COLOR`
environment variable is unset (https://no-color.org/).
* **Status, progress, warnings, and errors** go through the `internal/ui`
message methods below: marker-prefixed, colored on a TTY, and — except
warnings and errors — silenced by `--quiet`. This is the operational
narration of the long-running commands (`snapshot create`, `prune`,
`snapshot restore`, and the like) and the confirmations of
`config init`, `config set`, and `database delete`.
* **The data a command exists to produce** is written plain, with no
marker and no color, because a marker would corrupt a table or a
parsed document. This covers the `version`, `info`, and `remote info`
reports, the `snapshot list` table, `config get` values, and every
`--json` document. `--quiet` silences the human reports and tables
(`version`, `info`, `remote info`, `snapshot list`) but never the
machine-consumed `config get` value or the `--json` documents, which a
script depends on. The `database delete` confirmation prompt is also
written this way and always shown: it is an interactive exchange the
operator must see.
`internal/ui` writes to stdout; it is the output the user asked for.
Structured log records are a different thing and go through