Class: Abide::CLI::SceValidatePuppetStrings
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::SceValidatePuppetStrings
- Defined in:
- lib/abide_dev_utils/cli/sce.rb
Constant Summary collapse
- CMD_NAME =
'puppet-strings'
- CMD_SHORT =
'Validates the Puppet Strings documentation'
- CMD_LONG =
'Validates the Puppet Strings documentation'
Constants included from AbideDevUtils::Config
AbideDevUtils::Config::DEFAULT_PATH
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ SceValidatePuppetStrings
constructor
A new instance of SceValidatePuppetStrings.
Methods inherited from AbideCommand
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, to_h, #to_h
Constructor Details
#initialize ⇒ SceValidatePuppetStrings
Returns a new instance of SceValidatePuppetStrings.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/abide_dev_utils/cli/sce.rb', line 225 def initialize super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false) .on('-v', '--verbose', 'Verbose output') do @data[:verbose] = true end .on('-q', '--quiet', 'Quiet output') do @data[:quiet] = true end .on('-f [FORMAT]', '--format [FORMAT]', 'Format for output (text, json, yaml)') do |f| @data[:format] = f end .on('-o [FILE]', '--out-file [FILE]', 'Path to save the updated config file') do |o| @data[:out_file] = o end .on('-s', '--strict', 'Exits with exit code 1 if there are any warnings') do @data[:strict] = true end end |
Instance Method Details
#execute ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/abide_dev_utils/cli/sce.rb', line 244 def execute @data[:format] ||= 'text' AbideDevUtils::Validate.puppet_module_directory output = AbideDevUtils::Sce::Validate::Strings.validate(**@data) has_errors = false has_warnings = false output.each do |_, i| has_errors = true if i.any? { |j| j[:errors].any? } has_warnings = true if i.any? { |j| j[:warnings].any? } end AbideDevUtils::Output.send( @data[:format].to_sym, output, console: !@data[:quiet], file: @data[:out_file], stringify: true ) exit 1 if has_errors || (has_warnings && @data[:strict]) end |