Class: Abide::CLI::CemUpdateConfigFromDiff

Inherits:
AbideCommand
  • Object
show all
Defined in:
lib/abide_dev_utils/cli/cem.rb

Constant Summary collapse

CMD_NAME =
'from-diff'
CMD_SHORT =
'Update by diffing two XCCDF files'
CMD_LONG =
'Update by diffing two XCCDF files'
CMD_CONFIG_FILE =
'Path to the Puppet CEM config file'
CMD_CURRENT_XCCDF =
'Path to the current XCCDF file'
CMD_NEW_XCCDF =
'Path to the new XCCDF file'

Constants included from AbideDevUtils::Config

AbideDevUtils::Config::DEFAULT_PATH

Instance Method Summary collapse

Methods included from AbideDevUtils::Config

config_section, #config_section, fetch, #fetch, to_h, #to_h

Constructor Details

#initializeCemUpdateConfigFromDiff

Returns a new instance of CemUpdateConfigFromDiff.



147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/abide_dev_utils/cli/cem.rb', line 147

def initialize
  super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false)
  argument_desc(CONFIG_FILE: CMD_CONFIG_FILE, CURRENT_XCCDF: CMD_CURRENT_XCCDF, NEW_XCCDF: CMD_NEW_XCCDF)
  options.on('-o [FILE]', '--out-file [FILE]', 'Path to save the updated config file') do |o|
    @data[:out_file] = o
  end
  options.on('-v', '--verbose', 'Verbose output') do
    @data[:verbose] = true
  end
  options.on('-q', '--quiet', 'Quiet output') do
    @data[:quiet] = true
  end
end

Instance Method Details

#execute(config_file, cur_xccdf, new_xccdf) ⇒ Object



170
171
172
173
174
175
176
177
178
179
# File 'lib/abide_dev_utils/cli/cem.rb', line 170

def execute(config_file, cur_xccdf, new_xccdf)
  warn 'This command is currently non-functional'
  # AbideDevUtils::Validate.file(config_file, extension: 'yaml')
  # AbideDevUtils::Validate.file(cur_xccdf, extension: 'xml')
  # config_hiera = AbideDevUtils::Files::Reader.read(config_file, safe: true)
  # diff = AbideDevUtils::XCCDF::Diff::BenchmarkDiff.new(cur_xccdf, new_xccdf).diff[:diff][:number_title]
  # new_config_hiera, change_report = AbideDevUtils::CEM.update_legacy_config_from_diff(config_hiera, diff)
  # AbideDevUtils::Output.yaml(new_config_hiera, console: @data[:verbose], file: @data[:out_file])
  # AbideDevUtils::Output.simple(change_report) unless @data[:quiet]
end

#help_argumentsObject



161
162
163
164
165
166
167
168
# File 'lib/abide_dev_utils/cli/cem.rb', line 161

def help_arguments
  <<~ARGHELP
    Arguments:
      CONFIG_FILE:   #{CMD_CONFIG_FILE}
      CURRENT_XCCDF: #{CMD_CURRENT_XCCDF}
      NEW_XCCDF:     #{CMD_NEW_XCCDF}
  ARGHELP
end