Skip to content

Let ccrawl version render as data - #151

Merged
tamnd merged 1 commit into
mainfrom
version-honours-output
Aug 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
version-honours-output

Conversation

@tamnd

@tamnd tamnd commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Closes #150.

version wrote its line to stdout directly and never touched the renderer, so -o did nothing:

$ ccrawl version -o csv
ccrawl dev (commit none, built unknown, darwin/arm64, go1.26.5)

Six facts in a sentence, and a CI job that wants one of them has to write a regular expression against a format documented nowhere.

After

$ ccrawl version -o jsonl
{"arch":"arm64","built":"unknown","commit":"none","go":"go1.26.5","os":"darwin","version":"dev"}

$ ccrawl version -o csv
version,commit,built,os,arch,go
dev,none,unknown,darwin,arm64,go1.26.5

$ ccrawl version -o table
╭─────────┬────────┬─────────┬────────┬───────┬──────────╮
│ VERSION │ COMMIT │ BUILT   │ OS     │ ARCH  │ GO       │
...

What deliberately did not change

-o auto, the default, keeps the sentence, and keeps it in a pipe as well as on a terminal. Everywhere else auto means a table for a person and JSON Lines for a pipe, and following that here would turn ccrawl version | grep into a different string for everyone who already has it in a script. Asking for a format is how you say you want data. The test pins this, and a test run is a pipe, so it is the case that would have broken.

--short is untouched.

Why the other bare-value commands were left alone

This turned up in a sweep of the local commands after #140, so it is worth saying what else the sweep found and why nothing else moved. cache dir, library path, and config get each print one string. Wrapping one string in a JSON object helps nobody and would break cd "$(ccrawl cache dir)". version is different because it is a record wearing a sentence.

Checks

  • gofmt, go vet, go test ./..., docs-drift.sh, coverage.sh, golangci-lint run ./...
  • live: all four formats above, plus plain version and --short unchanged

docs/content/reference/cli.md gains a version section, which it did not have beyond a row in the command table.

The handler wrote to stdout directly and never touched the renderer, so -o did
nothing and a CI job that wanted the commit had to write a regular expression
against a line whose format is documented nowhere.

  ccrawl version -o json | jq -r .commit

auto keeps the sentence, in a pipe as well as on a terminal. Every other
command switches to JSON Lines when piped; this one does not, because that line
is what ccrawl version has always printed and asking for a format is how you
say you want data instead. --short is untouched.
@tamnd tamnd added this to the v0.10.1 milestone Aug 13, 2026
@tamnd tamnd added the bug Something isn't working label Aug 13, 2026
@tamnd
tamnd merged commit 8c3a2b3 into main Aug 13, 2026
8 checks passed
@tamnd
tamnd deleted the version-honours-output branch August 13, 2026 00:13
@github-actions github-actions Bot mentioned this pull request Aug 13, 2026
34 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ccrawl version ignores -o and prints one prose line

1 participant