Skip to content

Allow common flags to be set via HEXYL_* environment variables#272

Open
leno23 wants to merge 2 commits into
sharkdp:masterfrom
leno23:feat/env-vars-267
Open

Allow common flags to be set via HEXYL_* environment variables#272
leno23 wants to merge 2 commits into
sharkdp:masterfrom
leno23:feat/env-vars-267

Conversation

@leno23

@leno23 leno23 commented May 26, 2026

Copy link
Copy Markdown

Summary

  • Enable clap's env feature
  • Add HEXYL_PANELS, HEXYL_COLOR, HEXYL_CHARACTER_TABLE, and HEXYL_COLOR_SCHEME so frequently used options can be configured without repeating flags
  • Add integration tests for HEXYL_PANELS and HEXYL_COLOR

Fixes #267

Test plan

  • cargo test --test integration_tests env_vars
  • cargo test --test integration_tests (full suite locally)

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/main.rs
Comment on lines +106 to 107
env = "HEXYL_COLOR",
default_value_if("plain", ArgPredicate::IsPresent, Some("never"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/main.rs Outdated
#[arg(
long,
value_name("N"),
env = "HEXYL_PANELS"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
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.

Allow use of env vars instead of flags.

1 participant