Skip to content

Commit

Permalink
Add timing to each step
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Feb 6, 2024
1 parent 0aeb19f commit bb2121b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/foreman_maintain/reporter/cli_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bb2121b

Please sign in to comment.