From 987da645c20a14253f22216f8b1bdc9dc39df11e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 12 Feb 2021 21:43:56 -0500 Subject: [PATCH] core/cli: show run duration in human-readable format e.g. "Finished in 2h27m11s" I pray for your soul if you ever see "h". --- core/core-cli.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/core-cli.el b/core/core-cli.el index c186117e8..f282c1d80 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -494,8 +494,17 @@ Environment variables: (run-hooks 'doom-cli-pre-hook) (when (apply #'doom-cli-execute command args) (run-hooks 'doom-cli-post-hook) - (print! (success "Finished in %.4fs") - (float-time (time-subtract (current-time) start-time)))))))) + (print! (success "Finished in %s") + (let* ((duration (float-time (time-subtract (current-time) before-init-time))) + (hours (/ (truncate duration) 60 60)) + (minutes (- (/ (truncate duration) 60) (* hours 60))) + (seconds (- duration (* hours 60 60) (* minutes 60)))) + (string-join + (delq + nil (list (unless (zerop hours) (format "%dh" hours)) + (unless (zerop minutes) (format "%dm" minutes)) + (format (if (> duration 60) "%ds" "%.4fs") + seconds))))))))))) ;; TODO Not implemented yet (doom-cli-command-not-found-error (print! (error "Command 'doom %s' not recognized") (string-join (cdr e) " "))