Skip to content

Commit

Permalink
fix: partially reverted #220 due to unexpected breaking changes (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Apr 30, 2024
1 parent 0bfa282 commit 39b53b8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [".", "crate/encstr"]
[workspace.package]
repository = "https://github.com/pamburus/hl"
authors = ["Pavel Ivanov <mr.pavel.ivanov@gmail.com>"]
version = "0.28.1-alpha.6"
version = "0.28.1-alpha.7"
edition = "2021"
license = "MIT"

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ Filtering Options:
-q, --query <QUERY> Filter using query, accepts expressions from --filter and supports '(', ')', 'and', 'or', 'not', 'in', 'contain', 'like', '<', '>', '<=', '>=', etc

Output Options:
-c, --color [<WHEN>] Color output control [env: HL_COLOR=] [default: auto] [possible values: auto, always, never]
--color [<WHEN>] Color output control [env: HL_COLOR=] [default: auto] [possible values: auto, always, never]
-c Handful alias for --color=always, overrides --color option
--theme <THEME> Color theme [env: HL_THEME=] [default: universal]
-r, --raw Output raw source messages instead of formatted messages, which can be useful for applying filters and saving results in their original format
--no-raw Disable raw source messages output, overrides --raw option
Expand Down
11 changes: 9 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ pub struct Opt {
/// Color output control.
#[arg(
long,
short,
default_value = "auto",
env = "HL_COLOR",
overrides_with = "color",
overrides_with_all = ["color", "color_always"],
default_missing_value = "always",
num_args = 0..=1,
value_name = "WHEN",
Expand All @@ -114,6 +113,14 @@ pub struct Opt {
)]
pub color: ColorOption,

/// Handful alias for --color=always, overrides --color option.
#[arg(
short,
overrides_with_all = ["color", "color_always"],
help_heading = heading::OUTPUT
)]
pub color_always: bool,

/// Color theme.
#[arg(
long,
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ fn run() -> Result<()> {
};

// Configure color scheme.
let use_colors = match opt.color {
let color = if opt.color_always {
cli::ColorOption::Always
} else {
opt.color
};
let use_colors = match color {
cli::ColorOption::Auto => stdout().is_terminal() && color_supported,
cli::ColorOption::Always => true,
cli::ColorOption::Never => false,
Expand Down

0 comments on commit 39b53b8

Please sign in to comment.