Class: Abide::CLI::PuppetAuditClassNamesCommand

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

Constant Summary collapse

CMD_NAME =
'audit-class-names'
CMD_SHORT =
'Finds Puppet classes in a directory that have names that do not match their path'
CMD_LONG =
'Finds Puppet classes in a directory that have names that do not match their path. This is helpful because class names that do not match their path structure break Puppet autoloading.'
CMD_DIR_ARG =
'The directory containing the Puppet class files'

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

#initializePuppetAuditClassNamesCommand

Returns a new instance of PuppetAuditClassNamesCommand.



187
188
189
190
191
192
# File 'lib/abide_dev_utils/cli/puppet.rb', line 187

def initialize
  super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false)
  argument_desc(DIR: CMD_DIR_ARG)
  options.on('-o [FILE]', '--out-file [FILE]', 'Save results to a file') { |f| @data[:file] = f }
  options.on('-q', '--quiet', 'Do not print results to console') { @data[:quiet] = true }
end

Instance Method Details

#execute(dir) ⇒ Object



194
195
196
197
198
199
200
201
# File 'lib/abide_dev_utils/cli/puppet.rb', line 194

def execute(dir)
  if @data.fetch(:quiet, false) && !@data.key?(:file)
    AbideDevUtils::Output.simple('ERROR: Specifying --quiet without --out-file is useless.', stream: $stderr)
    exit 1
  end

  AbideDevUtils::Ppt.audit_class_names(dir, **@data)
end