Skip to content

feat(cli): migrate --log-format/--force-tty-if-json to clap-native env=#355

Merged
pofallon merged 1 commit into
mainfrom
feat/env-migrate-logformat-forcetty
Jul 22, 2026
Merged

feat(cli): migrate --log-format/--force-tty-if-json to clap-native env=#355
pofallon merged 1 commit into
mainfrom
feat/env-migrate-logformat-forcetty

Conversation

@pofallon

Copy link
Copy Markdown
Contributor

Summary

Category B of #180 (part 2 of 2, follows #354). Moves the last two flag-backed env vars onto clap's env= — and fixes a latent flag-vs-env bug in up that this migration exposed.

Flag Env var Change
--log-format DEACON_LOG_FORMAT env= added; is_json_log_format() drops its manual env fallback and reads the clap-resolved field
--force-tty-if-json DEACON_FORCE_TTY_IF_JSON env= added (clap boolish parse); resolve_force_pty drops its manual env branch

Latent bug fixed

up's lifecycle (lifecycle.rs) and compose (compose.rs) PTY gating re-read DEACON_LOG_FORMAT from the environment directly (v == "json"). So --log-format json passed as a flag (with no env var set) never set json_mode there, and the PTY-force path was silently skipped. Fixed by threading the clap-resolved value through a new UpArgs.json_log_format field; the deep sites now read args.json_log_format instead of the environment.

Details

  • Removed the now-dead ENV_LOG_FORMAT const. ENV_FORCE_TTY_IF_JSON stays — it's injected into the container env (up/mod.rs), which is out of Migrate manually-read flag-backed env vars to clap-native env= #180 scope.
  • LogFormat gains PartialEq/Eq.
  • temp-env parse tests (env / flag-beats-env / falsey). Three existing env-dependent tests now pin the env explicitly so they're deterministic under a shared-process runner too (nextest already isolates per-process).
  • The docker-gated integration_up_force_tty_if_json assertions are lenient (command succeeds + valid JSON), so the json-mode correctness change doesn't disturb them.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • make test-nextest-fast — 3105 passed, 31 skipped ✓
  • --help verified to advertise [env: …] for both.

This completes Category B of #180. Category A (net-new env vars) tracked as an optional follow-up.

🤖 Generated with Claude Code

Category B of #180 (part 2). Move the last two flag-backed env vars onto
clap's `env=` and, in doing so, fix a latent flag-vs-env bug in `up`.

- `--log-format` gains `env = "DEACON_LOG_FORMAT"`; `is_json_log_format()`
  drops its manual env fallback and just reads the clap-resolved field.
- `--force-tty-if-json` gains `env = "DEACON_FORCE_TTY_IF_JSON"`;
  `resolve_force_pty` drops its manual env branch (clap boolish parse owns it).
- Latent bug fix: `up`'s lifecycle and compose PTY gating re-read
  `DEACON_LOG_FORMAT` from the environment directly, so `--log-format json`
  passed as a *flag* (no env var) never triggered json-mode there. Thread the
  clap-resolved value through a new `UpArgs.json_log_format` field instead;
  the deep sites now read `args.json_log_format`. Removed the now-dead
  `ENV_LOG_FORMAT` const (`ENV_FORCE_TTY_IF_JSON` stays — it is injected into
  the container env, which is out of #180 scope).
- `LogFormat` gains `PartialEq`/`Eq`; temp-env parse tests (env / flag-beats-env
  / falsey) added; three existing env-dependent tests now pin the env explicitly
  so they stay deterministic under a shared-process runner too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vhr7Tcf8ybvSZSE1owqBT
@github-actions github-actions Bot added the feature New feature (alias) label Jul 22, 2026
@pofallon
pofallon merged commit 82248b6 into main Jul 22, 2026
21 of 22 checks passed
@pofallon
pofallon deleted the feat/env-migrate-logformat-forcetty branch July 22, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (alias)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant