Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Enabled overriding for most of the command line options #136

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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 @@ 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"

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ Options:
-P Handful alias for --paging=never, overrides --paging option
--theme <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 <INTERRUPT_IGNORE_COUNT> Number of interrupts to ignore, i.e. Ctrl-C (SIGINT) [env: HL_INTERRUPT_IGNORE_COUNT=] [default: 3]
Expand All @@ -460,6 +461,7 @@ Options:
-t, --time-format <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> 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 <INPUT_INFO> Show input number and/or input filename before each message [default: auto] [possible values: auto, none, full, compact, minimal]
Expand Down
30 changes: 19 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -119,11 +123,11 @@ struct Opt {
level: Option<RelaxedLevel>,
//
/// 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<String>,
//
/// 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<String>,
//
/// Time format, see https://man7.org/linux/man-pages/man1/date.1.html.
Expand All @@ -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<PathBuf>,
Expand Down Expand Up @@ -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<String>,

/// Dump index metadata and exit.
Expand Down
Loading