Class: Abide::CLI::PuppetAddCISCommentCommand

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

Constant Summary collapse

CMD_NAME =
'add-cis-comment'
CMD_SHORT =
'Adds the CIS recommendation name to the top of a .pp file'
CMD_LONG =
'Adds the CIS recommendation name to the top of a .pp file. Finds CIS recommendation by pattern-matching the class name against XCCDF recommendations.'
CMD_PATH_ARG =
'Path to a .pp file or to a directory containing .pp files'
CMD_XCCDF_ARG =
'Path to XCCDF file to source recommendation names from'

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

#initializePuppetAddCISCommentCommand

Returns a new instance of PuppetAddCISCommentCommand.



210
211
212
213
214
# File 'lib/abide_dev_utils/cli/puppet.rb', line 210

def initialize
  super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false)
  argument_desc(PATH: CMD_PATH_ARG, XCCDF: CMD_XCCDF_ARG)
  options.on('-N', '--number-format', 'Matches based on number-formatted control class names') { @data[:number_format] = true }
end

Instance Method Details

#execute(path, xccdf) ⇒ Object



216
217
218
# File 'lib/abide_dev_utils/cli/puppet.rb', line 216

def execute(path, xccdf)
  AbideDevUtils::Ppt.add_cis_comment(path, xccdf, number_format: @data.fetch(:number_format, false))
end