From 6a2b0a67b0ad8143f223f7abc6562ac839875b88 Mon Sep 17 00:00:00 2001 From: Luca Rinaldi Date: Thu, 19 Dec 2019 14:38:06 -0800 Subject: feat: cmd_duration module optionally reports milliseconds (#696) --- src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2f995f0df..9fb1e0fee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use std::time::SystemTime; + #[macro_use] extern crate clap; @@ -44,7 +46,7 @@ fn main() { .short("d") .long("cmd-duration") .value_name("CMD_DURATION") - .help("The execution duration of the last command, in seconds") + .help("The execution duration of the last command, in milliseconds") .takes_value(true); let keymap_arg = Arg::with_name("keymap") @@ -115,6 +117,11 @@ fn main() { .subcommand(SubCommand::with_name("bug-report").about( "Create a pre-populated GitHub issue with information about your configuration", )) + .subcommand( + SubCommand::with_name("time") + .about("Prints time in milliseconds") + .settings(&[AppSettings::Hidden]), + ) .get_matches(); match matches.subcommand() { @@ -141,6 +148,15 @@ fn main() { } ("configure", Some(_)) => configure::edit_configuration(), ("bug-report", Some(_)) => bug_report::create(), + ("time", _) => { + match SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .ok() + { + Some(time) => println!("{}", time.as_millis()), + None => println!("{}", -1), + } + } _ => {} } } -- cgit v1.2.3