From 903306030f59554ff6fd73146fd30c2330504358 Mon Sep 17 00:00:00 2001 From: euxane Date: Sat, 30 Nov 2024 09:58:49 +0100 Subject: cli: add option for timestamp line header format --- main.nim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'main.nim') diff --git a/main.nim b/main.nim index 3128bac..cca5528 100644 --- a/main.nim +++ b/main.nim @@ -37,6 +37,7 @@ proc main() = var scale: Scale = log2 symbols = UNICODE_SYMBOLS + timestampHeader = formatTimestampDateTime (min, max) = (0, 1000) probe: (timeout: Duration) -> int @@ -66,6 +67,12 @@ proc main() = of "unicode", "utf8", "utf-8": symbols = UNICODE_SYMBOLS of "numeric", "ascii": symbols = NUMERIC_SYMBOLS + of "timestamp": + case val: + of "datetime", "date-time": timestampHeader = formatTimestampDateTime + of "unix", "epoch": timestampHeader = formatTimestampUnix + of "none", "false": timestampHeader = formatTimestampNone + of "range": let parts = val.split(':', 1) if parts.len != 2: raise newException(ValueError, "Invalid range") @@ -87,7 +94,11 @@ proc main() = if probe == nil: raise newException(ValueError, "Missing monitor argument") - loop(probe, (val: int) => symbols.indicator(min, max, val, scale)) + loop( + probe, + (val: int) => symbols.indicator(min, max, val, scale), + timestampHeader, + ) when not defined(test): -- cgit v1.2.3