From 633196e6dc071ec4dd31a969ada5839babd7e819 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Thu, 31 Aug 2023 14:52:02 -0400 Subject: [PATCH] tweak --help menu --- Cargo.toml | 2 +- README.md | 34 +++++++++++++++++++++++++++++----- src/main.rs | 31 ++++++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9f98e1e..6b8ebe1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "utcnow" -version = "1.5.0" +version = "1.5.1" authors = ["Jonathan Strong "] edition = "2021" diff --git a/README.md b/README.md index 2af1442..0d3a8a3 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,45 @@ ```console -utcnow 1.0.0 -Jonathan Strong +$ utcnow -h +utcnow 1.5.0 +Jonathan Strong current time in utc with non-cryptic interface. -for your own safety and well-being, local time functionality is not provided. + $ utcnow + >> 2023-08-31T18:20:06.190019513Z + + $ utcnow -R 1693505148834000000 + >> 2023-08-31T18:05:48.834000000Z + + $ utcnow -U 2023-08-31T18:05:48.834000000Z + >> 1693505148834000000 -default output format is rfc3339 with trailing 'Z', e.g. '1999-12-31T23:59:59.999999999Z' + $ utcnow --unix + >> 1693506028080252547 + + $ utcnow --millis + >> 2023-08-31T18:20:14.672Z + + $ utcnow --unix --millis + >> 1693506584321 USAGE: - utcnow [FLAGS] + utcnow [FLAGS] [OPTIONS] FLAGS: + -E, --est display in us/eastern timezone -h, --help help + -m, --millis display unix timestamp in milliseconds, instead of default nanoseconds + -0, --null terminate displayed time with null character instead of newline -r, --rfc2822 display in rfc2822 format -s, --seconds display unix timestamp in seconds, instead of default nanoseconds -t, --timespec display as , -u, --unix display elapsed nanoseconds since 1970-01-01T00:00:00Z -V, --version version + +OPTIONS: + -U, --rfc3339-to-unix parse rfc3339 timestamp and display it as a unix timestamp + -R, --unix-to-rfc3339 convert integer unix timestamp (nanoseconds precision) to datetime in + rfc3339 format. combine with --seconds or --millis to parse a seconds + timestamp with alternate precison ``` diff --git a/src/main.rs b/src/main.rs index 5f90061..197cfcb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![allow(unused)] + use std::str::FromStr; use chrono::{DateTime, Utc, NaiveDateTime, TimeZone}; @@ -31,8 +32,8 @@ fn main() { let args: clap::ArgMatches = clap::App::new("utcnow") .author("Jonathan Strong ") .version(clap::crate_version!()) - .about("\ncurrent time in utc with non-cryptic interface.\n\n\ - default output format is rfc3339 with trailing 'Z', e.g. '1999-12-31T23:59:59.999999999Z'") + //.about("current time in utc with non-cryptic interface") + .about(LONG_HELP) .help_message("help") .version_message("version") .arg(clap::Arg::with_name("unix") @@ -78,7 +79,7 @@ fn main() { .short("R") .alias("unix-to-utc") .help("convert integer unix timestamp (nanoseconds precision) to datetime \ - in rfc3339 format. combine with --seconds or --millis to parse a + in rfc3339 format. combine with --seconds or --millis to parse a \ seconds timestamp with alternate precison") .takes_value(true) .required(false) @@ -183,3 +184,27 @@ fn main() { print!("{}{}", time_str, endline); } } + +//const LONG_HELP: &str = include_str!("../long-help.txt"); + +const LONG_HELP: &str = "current time in utc with non-cryptic interface. + + $ utcnow + >> 2023-08-31T18:20:06.190019513Z + + $ utcnow -R 1693505148834000000 + >> 2023-08-31T18:05:48.834000000Z + + $ utcnow -U 2023-08-31T18:05:48.834000000Z + >> 1693505148834000000 + + $ utcnow --unix + >> 1693506028080252547 + + $ utcnow --millis + >> 2023-08-31T18:20:14.672Z + + $ utcnow --unix --millis + >> 1693506584321"; + +