Allow common flags to be set via HEXYL_* environment variables#272
Allow common flags to be set via HEXYL_* environment variables#272leno23 wants to merge 2 commits into
Conversation
Enable clap's env feature and wire HEXYL_PANELS, HEXYL_COLOR, HEXYL_CHARACTER_TABLE, and HEXYL_COLOR_SCHEME so users can configure hexyl without repeating flags on every invocation. Fixes sharkdp#267 Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c092340f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| env = "HEXYL_COLOR", | ||
| default_value_if("plain", ArgPredicate::IsPresent, Some("never")) |
There was a problem hiding this comment.
Respect
--plain over HEXYL_COLOR
Adding env = "HEXYL_COLOR" makes an ambient environment variable override the default_value_if("plain", ...) behavior, so hexyl --plain can render with colors when HEXYL_COLOR=always (or auto on a TTY). That breaks the documented --plain contract (it should imply --color=never) for users who set a global color preference in their shell.
Useful? React with 👍 / 👎.
| #[arg( | ||
| long, | ||
| value_name("N"), | ||
| env = "HEXYL_PANELS" |
There was a problem hiding this comment.
Let
--terminal-width work when HEXYL_PANELS is set
Binding --panels to HEXYL_PANELS causes terminal_width's existing conflicts_with("panels") rule to fire whenever that env var is present, so hexyl --terminal-width <N> fails unless users unset the env var first. This turns a default-like environment setting into a hard global lockout for another common option.
Useful? React with 👍 / 👎.
Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
envfeatureHEXYL_PANELS,HEXYL_COLOR,HEXYL_CHARACTER_TABLE, andHEXYL_COLOR_SCHEMEso frequently used options can be configured without repeating flagsHEXYL_PANELSandHEXYL_COLORFixes #267
Test plan
cargo test --test integration_tests env_varscargo test --test integration_tests(full suite locally)