Skip to content

Commit

Permalink
Optionally save generated report to file
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Jan 16, 2025
1 parent 10fc9c2 commit d7c3ef5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/foreman_maintain/cli/report_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ module Cli
class ReportCommand < Base
extend Concerns::Finders

option '--output', 'FILE', 'Output the generate report into FILE'
subcommand 'generate', 'Generates the usage reports' do
def execute
scenario = run_scenario(Scenarios::Report::Generate.new({}, [:reports])).first

# description can be used too
report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
report_data['version'] = 1
puts report_data.to_yaml
yaml = report_data.to_yaml
if @output
File.write(@output, yaml)
else
puts yaml
end
exit runner.exit_code
end
end
Expand Down

0 comments on commit d7c3ef5

Please sign in to comment.