From bb2121bc7d77ccd01300353d6633b56b70154b8a Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 6 Apr 2023 21:17:21 -0400 Subject: [PATCH] Add timing to each step --- lib/foreman_maintain/reporter/cli_reporter.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/foreman_maintain/reporter/cli_reporter.rb b/lib/foreman_maintain/reporter/cli_reporter.rb index 681fc730a..01e2acf33 100644 --- a/lib/foreman_maintain/reporter/cli_reporter.rb +++ b/lib/foreman_maintain/reporter/cli_reporter.rb @@ -150,7 +150,12 @@ def with_spinner(message) end def after_execution_finishes(execution) - puts_status(execution.status) + if execution.started_at + puts_status(execution.status, execution.ended_at - execution.started_at) + else + puts_status(execution.status) + end + puts(execution.output) unless execution.output.empty? puts(already_run_msg) if execution.status == :already_run hline @@ -258,14 +263,16 @@ def execution_info(execution, text) "#{prefix} #{text}" end - def puts_status(status) - label_offset = 10 + def puts_status(status, runtime = nil) + label_offset = 12 padding = @max_length - @last_line.to_s.size - label_offset if padding < 0 new_line_if_needed padding = @max_length - label_offset end - @stdout.print(' ' * padding + status_label(status)) + output = ' ' * padding + status_label(status) + output += runtime ? " [#{runtime.truncate(2).to_s}]" : '' + @stdout.print(output) @new_line_next_time = true end