Skip to content

Commit

Permalink
Merge pull request #11 from adamruzicka/file-output
Browse files Browse the repository at this point in the history
Optionally save generated report to file
  • Loading branch information
ShimShtein authored Jan 16, 2025
2 parents 10fc9c2 + d7c3ef5 commit 0099555
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 0099555

Please sign in to comment.