summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorLuca Rinaldi <lucarin@protonmail.com>2019-12-19 14:38:06 -0800
committerMatan Kushner <hello@matchai.me>2019-12-19 17:38:06 -0500
commit6a2b0a67b0ad8143f223f7abc6562ac839875b88 (patch)
tree4d11fe667909296448c95dcd82fe33d917d1abec /src/main.rs
parentd6094d7b9d300462d0a9de21da5d1cdbb07794a4 (diff)
feat: cmd_duration module optionally reports milliseconds (#696)
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 17 insertions, 1 deletions
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),
+ }
+ }
_ => {}
}
}