Class: Abide::CLI::XccdfDiffCommand
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::XccdfDiffCommand
- Defined in:
- lib/abide_dev_utils/cli/xccdf.rb
Constant Summary collapse
- CMD_NAME =
'diff'
- CMD_SHORT =
'Generates a diff report between two XCCDF files'
- CMD_LONG =
'Generates a diff report between two XCCDF files'
- CMD_FILE1_ARG =
'path to first XCCDF file'
- CMD_FILE2_ARG =
'path to second XCCDF file'
Constants included from AbideDevUtils::Config
AbideDevUtils::Config::DEFAULT_PATH
Instance Method Summary collapse
- #execute(file1, file2) ⇒ Object
-
#initialize ⇒ XccdfDiffCommand
constructor
A new instance of XccdfDiffCommand.
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, to_h, #to_h
Constructor Details
#initialize ⇒ XccdfDiffCommand
Returns a new instance of XccdfDiffCommand.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/abide_dev_utils/cli/xccdf.rb', line 103 def initialize super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false) argument_desc(FILE1: CMD_FILE1_ARG, FILE2: CMD_FILE2_ARG) .on('-o [PATH]', '--out-file', 'Save the report as a yaml file') { |x| @data[:outfile] = x } .on('-p [PROFILE]', '--profile', 'Only diff and specific profile in the benchmarks') do |x| @data[:profile] = x end .on('-l [LEVEL]', '--level', 'Only diff the specific level in the benchmarks') do |x| @data[:level] = x end .on('-r', '--raw', 'Output the diff in raw hash format') { @data[:raw] = true } .on('-q', '--quiet', 'Show no output in the terminal') { @data[:quiet] = false } .on('--no-diff-profiles', 'Do not diff the profiles in the XCCDF files') { @data[:diff_profiles] = false } .on('--no-diff-controls', 'Do not diff the controls in the XCCDF files') { @data[:diff_controls] = false } .on('--old-style', 'Use old-style diffs') { @data[:old_style] = true } end |
Instance Method Details
#execute(file1, file2) ⇒ Object
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/abide_dev_utils/cli/xccdf.rb', line 120 def execute(file1, file2) diffreport = if @data[:old_style] AbideDevUtils::XCCDF.diff(file1, file2, @data) else dr = AbideDevUtils::XCCDF.new_style_diff(file1, file2, @data) dr[:diff][:number_title].map! { |d| d[:text] } dr end AbideDevUtils::Output.yaml(diffreport, console: @data.fetch(:quiet, true), file: @data.fetch(:outfile, nil)) end |