feat(cli): migrate --log-format/--force-tty-if-json to clap-native env=#355
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inupthat this migration exposed.--log-formatDEACON_LOG_FORMATenv=added;is_json_log_format()drops its manual env fallback and reads the clap-resolved field--force-tty-if-jsonDEACON_FORCE_TTY_IF_JSONenv=added (clap boolish parse);resolve_force_ptydrops its manual env branchLatent bug fixed
up's lifecycle (lifecycle.rs) and compose (compose.rs) PTY gating re-readDEACON_LOG_FORMATfrom the environment directly (v == "json"). So--log-format jsonpassed as a flag (with no env var set) never setjson_modethere, and the PTY-force path was silently skipped. Fixed by threading the clap-resolved value through a newUpArgs.json_log_formatfield; the deep sites now readargs.json_log_formatinstead of the environment.Details
ENV_LOG_FORMATconst.ENV_FORCE_TTY_IF_JSONstays — 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.LogFormatgainsPartialEq/Eq.integration_up_force_tty_if_jsonassertions 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 ✓--helpverified 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