Skip to content

fix(cli): keep --version and --json free of terminal styling - #1

Merged
schiz0x00 merged 1 commit into
mainfrom
dev
Aug 1, 2026
Merged

fix(cli): keep --version and --json free of terminal styling#1
schiz0x00 merged 1 commit into
mainfrom
dev

Conversation

@schiz0x00

Copy link
Copy Markdown
Owner

CI on `main` failed on the initial push. Three help tests passed locally and failed in Actions, which turned out to be surfacing two real bugs rather than flaky tests.

What was broken

rich highlights whatever it prints, and enables colour when it detects a CI terminal:

  • `--version` emitted `\x1b[1;36m0.1\x1b[0m.\x1b[1;36m0\x1b[0m`, so `VERSION=$(instadata --version)` captured escape codes.
  • `--json` emitted syntax-highlighted JSON that did not parse — verified with `json.loads`.

Both flags exist to be consumed by other programs. Both now go through plain `print`, via a shared `emit_json` helper.

Test fragility behind it

The help assertions read rendered bytes, so they depended on colour and width — `--proxy` stops being a contiguous substring once typer styles it. They now strip styling before matching, and `conftest` pins `NO_COLOR` and a wide `COLUMNS` so a local run sees what CI sees.

Verified green across plain, `CI=true`, `FORCE_COLOR=1`, and `COLUMNS=40`.

Also fixes an epilog line still naming the pre-rename command.

Note

Merging this triggers `release.yml`, which will publish 0.1.0 to PyPI. That version number is permanent once used.

rich highlights whatever it prints, so --version emitted the version with
escape codes spliced through it and --json emitted syntax-highlighted
JSON that did not parse. Both exist to be consumed by other programs, so
both now go through plain print.

Caught by CI: rich enables colour when it detects a CI terminal, which
the local test run never does.

The help assertions were reading rendered bytes, which made them depend
on colour and width, so they now strip styling before matching. conftest
also pins NO_COLOR and a wide COLUMNS so a developer sees the same output
the tests do.

Also fixes an epilog line still referring to the pre-rename command name.
@schiz0x00
schiz0x00 merged commit 00c3354 into main Aug 1, 2026
8 checks passed
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