feat(cli): migrate --runtime/--no-redact/--log-level to clap-native env=#354
Merged
Merged
Conversation
Category B of #180: three flag-backed env vars were read by hand below the CLI layer. Move them onto clap's `env=` attribute so clap owns the precedence (flag > env > default) and `--help` advertises `[env: …]` for free. - `--runtime` gains `env = "DEACON_CONTAINER_RUNTIME"`; `RuntimeFactory:: detect_runtime` drops its manual env branch and is now a pure flag-or-default resolver (env is resolved at the CLI tier and threaded down via every caller's `self.runtime`). The issue's `DEACON_RUNTIME` premise was stale — the code already read `DEACON_CONTAINER_RUNTIME`, matching doctor. - `--no-redact` gains `env = "DEACON_NO_REDACT"` (clap boolish parse). - `--log-level` gains `env = "DEACON_LOG_LEVEL"`; previously this var was only a doctor diagnostic and never actually backed the flag — now it does, with DEACON_LOG/RUST_LOG still winning for the effective directive. - doctor's env snapshot now lists DEACON_CONTAINER_RUNTIME and DEACON_NO_REDACT for discoverability; its reads stay diagnostic (the one legitimate exception). - temp-env parse tests (flag / env / flag-beats-env) per var, mirroring the DEACON_OVERRIDE_CONFIG template; runtime.rs env tests move to the CLI layer. - Document the clap-`env=` convention in CLAUDE.md for future flag additions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019vhr7Tcf8ybvSZSE1owqBT
This was referenced Jul 22, 2026
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 1 of 2). Three flag-backed env vars were read by hand below the CLI layer; this moves them onto clap's
env=attribute so clap owns precedence (flag > env > default) and--helpadvertises[env: …]for free.--runtimeDEACON_CONTAINER_RUNTIMEenv=added;RuntimeFactory::detect_runtimedrops its manual env branch (now flag-or-default; env resolved at CLI tier, threaded viaself.runtime)--no-redactDEACON_NO_REDACTenv=added (clap boolish parse)--log-levelDEACON_LOG_LEVELenv=added — previously this var was only a doctor diagnostic and never actually backed the flag; now it does (DEACON_LOG/RUST_LOG still win for the effective directive)Stale-issue notes
detect_runtimereadsDEACON_RUNTIMEis stale — it already readDEACON_CONTAINER_RUNTIME, matching whatdoctorreports, so the "reconcile names" item was already satisfied.detect_runtimerefactor" is moot: no such warning exists indetect_runtime.Details
doctor's env snapshot now listsDEACON_CONTAINER_RUNTIMEandDEACON_NO_REDACTfor discoverability; its reads stay diagnostic (the one legitimate exception to the no-hand-rolled-read rule).DEACON_OVERRIDE_CONFIGtemplate. Theruntime.rsenv-precedence tests move to the CLI layer where the env is now resolved.env=convention is documented inCLAUDE.mdfor future flag additions.Follow-ups
--log-format,--force-tty-if-json): meatier because their env reads live deep in theupflow — will thread the resolved json-mode intoUpArgs(fixing a latent bug where--log-format jsonas a flag doesn't trigger PTY gating that only reads the env var).Testing
cargo fmt --all -- --check✓cargo clippy --all-targets --all-features -- -D warnings✓make test-nextest-fast— 3095 passed, 31 skipped ✓--helpverified to advertise[env: …]for all three.🤖 Generated with Claude Code