Skip to content

Keep structured command output clean - #1831

Open
JordanNoone wants to merge 4 commits into
mainfrom
codex/structured-output-stderr-1757
Open

Keep structured command output clean#1831
JordanNoone wants to merge 4 commits into
mainfrom
codex/structured-output-stderr-1757

Conversation

@JordanNoone

@JordanNoone JordanNoone commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add --json to file conversion, project publication, and project upload
  • preserve the existing human-readable default: table-mode status messages remain on stdout
  • keep stdout machine-readable for --json, --format=json, and --format=yaml by sending status messages to stderr
  • reject ambiguous combinations of --json with --format

Tests

  • cargo fmt --all -- --check
  • cargo check --all-targets
  • cargo clippy --all-targets -- -D warnings
  • cargo test cmd_project::tests
  • cargo test cmd_file::test
  • verified help output for all three commands and the --json/--format conflict

The token-backed conversion integration test now covers both the unchanged default output and the new --json behavior in CI.

Closes #1757

@JordanNoone
JordanNoone marked this pull request as ready for review August 31, 2026 02:12
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.97%. Comparing base (8d886cc) to head (e74fc2a).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1831   +/-   ##
=======================================
  Coverage   65.97%   65.97%           
=======================================
  Files          43       43           
  Lines        8434     8436    +2     
=======================================
+ Hits         5564     5566    +2     
  Misses       2870     2870           
Flag Coverage Δ
unittests 65.97% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jessfraz

jessfraz commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

can you explain why, this isnt traditional for a cli, in most cases youd want something human readable in stdout unless the user gives a --json flag for only json output

@JordanNoone

Copy link
Copy Markdown
Contributor Author

Updated based on this feedback: the affected commands now have an explicit --json flag. Without it, the default/table behavior is preserved and human-readable status stays on stdout. With --json, stdout contains only JSON and status moves to stderr. Existing explicit --format=json and --format=yaml remain machine-clean, and --json conflicts with --format to avoid ambiguity.

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.

Structured-output commands print human progress text to stdout, breaking --format json | jq

2 participants