From 6a75ee00ddd413da1e82241fd67f5d90dbeb7369 Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Sat, 24 Feb 2024 22:27:24 +0100 Subject: [PATCH] new: enabled overriding for most of the command line options --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 ++ src/main.rs | 30 +++++++++++++++++++----------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5e73c20..c64531c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,7 +738,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hl" -version = "0.25.3-alpha.1" +version = "0.25.3-alpha.2" dependencies = [ "atoi", "bincode", diff --git a/Cargo.toml b/Cargo.toml index f0895a16..dcb331f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ categories = ["command-line-utilities"] description = "Utility for viewing json-formatted log files." keywords = ["cli", "human", "log"] name = "hl" -version = "0.25.3-alpha.1" +version = "0.25.3-alpha.2" edition = "2021" build = "build.rs" diff --git a/README.md b/README.md index 9fa4212b..a0edb07f 100644 --- a/README.md +++ b/README.md @@ -445,6 +445,7 @@ Options: -P Handful alias for --paging=never, overrides --paging option --theme Color theme [env: HL_THEME=] [default: universal] -r, --raw Output raw JSON messages instead of formatter messages, it can be useful for applying filters and saving results in original format + --no-raw Disable raw JSON messages output, overrides --raw option --raw-fields Disable unescaping and prettifying of field values --allow-prefix Allow non-JSON prefixes before JSON messages [env: HL_ALLOW_PREFIX=] --interrupt-ignore-count Number of interrupts to ignore, i.e. Ctrl-C (SIGINT) [env: HL_INTERRUPT_IGNORE_COUNT=] [default: 3] @@ -460,6 +461,7 @@ Options: -t, --time-format Time format, see https://man7.org/linux/man-pages/man1/date.1.html [env: HL_TIME_FORMAT=] [default: "%y-%m-%d %T.%3N"] -Z, --time-zone Time zone name, see column "TZ identifier" at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones [env: HL_TIME_ZONE=] [default: UTC] -L, --local Use local time zone, overrides --time-zone option + --no-local Disable local time zone, overrides --local option -e, --hide-empty-fields Hide empty fields, applies for null, string, object and array fields only [env: HL_HIDE_EMPTY_FIELDS=] -E, --show-empty-fields Show empty fields, overrides --hide-empty-fields option [env: HL_SHOW_EMPTY_FIELDS=] --input-info Show input number and/or input filename before each message [default: auto] [possible values: auto, none, full, compact, minimal] diff --git a/src/main.rs b/src/main.rs index 8da25186..1710e295 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,15 +69,19 @@ struct Opt { theme: String, // /// Output raw JSON messages instead of formatter messages, it can be useful for applying filters and saving results in original format. - #[arg(short, long)] + #[arg(short, long, overrides_with = "raw")] raw: bool, // + /// Disable raw JSON messages output, overrides --raw option. + #[arg(long, overrides_with = "raw")] + _no_raw: bool, + // /// Disable unescaping and prettifying of field values. - #[arg(long)] + #[arg(long, overrides_with = "raw_fields")] raw_fields: bool, // /// Allow non-JSON prefixes before JSON messages. - #[arg(long, env = "HL_ALLOW_PREFIX")] + #[arg(long, env = "HL_ALLOW_PREFIX", overrides_with = "allow_prefix")] allow_prefix: bool, // /// Number of interrupts to ignore, i.e. Ctrl-C (SIGINT). @@ -119,11 +123,11 @@ struct Opt { level: Option, // /// Filtering by timestamp >= the value (--time-zone and --local options are honored). - #[arg(long, allow_hyphen_values = true)] + #[arg(long, allow_hyphen_values = true, overrides_with = "since")] since: Option, // /// Filtering by timestamp <= the value (--time-zone and --local options are honored). - #[arg(long, allow_hyphen_values = true)] + #[arg(long, allow_hyphen_values = true, overrides_with = "until")] until: Option, // /// Time format, see https://man7.org/linux/man-pages/man1/date.1.html. @@ -141,9 +145,13 @@ struct Opt { time_zone: chrono_tz::Tz, // /// Use local time zone, overrides --time-zone option. - #[arg(long, short = 'L')] + #[arg(long, short = 'L', overrides_with = "local")] local: bool, // + /// Disable local time zone, overrides --local option. + #[arg(long, overrides_with = "local")] + _no_local: bool, + // /// Files to process #[arg(name = "FILE")] files: Vec, @@ -176,23 +184,23 @@ struct Opt { list_themes: bool, /// Sort messages chronologically. - #[arg(long, short = 's')] + #[arg(long, short = 's', overrides_with = "sort")] sort: bool, /// Follow input streams and sort messages chronologically during time frame set by --sync-interval-ms option. - #[arg(long, short = 'F')] + #[arg(long, short = 'F', overrides_with = "follow")] follow: bool, /// Number of last messages to preload from each file in --follow mode. - #[arg(long, default_value = "10")] + #[arg(long, default_value = "10", overrides_with = "tail")] tail: u64, /// Synchronization interval for live streaming mode enabled by --follow option. - #[arg(long, default_value = "100")] + #[arg(long, default_value = "100", overrides_with = "sync-interval-ms")] sync_interval_ms: u64, /// Output file. - #[arg(long, short = 'o')] + #[arg(long, short = 'o', overrides_with = "output")] output: Option, /// Dump index metadata and exit.