Class: Abide::CLI::SceGenerateReference
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::SceGenerateReference
- Defined in:
- lib/abide_dev_utils/cli/sce.rb
Constant Summary collapse
- CMD_NAME =
'reference'
- CMD_SHORT =
'Generates a reference doc for the module'
- CMD_LONG =
'Generates a reference doc for the module'
Constants included from AbideDevUtils::Config
AbideDevUtils::Config::DEFAULT_PATH
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ SceGenerateReference
constructor
A new instance of SceGenerateReference.
Methods inherited from AbideCommand
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, to_h, #to_h
Constructor Details
#initialize ⇒ SceGenerateReference
Returns a new instance of SceGenerateReference.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/abide_dev_utils/cli/sce.rb', line 98 def initialize super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false) .on('-o [FILE]', '--out-file [FILE]', 'Path to save the updated config file') do |o| @data[:out_file] = o end .on('-f [FORMAT]', '--format [FORMAT]', 'Format to save reference as') do |f| @data[:format] = f end .on('-v', '--verbose', 'Verbose output') do @data[:debug] = true end .on('-q', '--quiet', 'Quiet output') do @data[:quiet] = true end .on('-s', '--strict', 'Fails if there are any errors') do @data[:strict] = true end .on('-p [PROFILE]', '--select-profile [PROFILE]', 'The list of profiles that the reference.md will use separated by commas') do |pr| @data[:select_profile] = pr.split(',') end .on('-l [LEVEL]', '--select-level [LEVEL]', 'The list of level that the reference.md will use separated by commas') do |l| @data[:select_level] = l.split(',') end end |
Instance Method Details
#execute ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/abide_dev_utils/cli/sce.rb', line 125 def execute AbideDevUtils::Validate.puppet_module_directory errors, warnings = AbideDevUtils::Sce::Generate::Reference.generate(@data) errors.each do |err| output = ["[error]: #{err.}"] # Errors should all be instances of AbideDevUtils::Errors::BenchmarkLoadError # We check that the extra methods on this error are valid before calling them, though, because # other errors might be returned somehow. if err.respond_to?(:osname) && err.respond_to?(:major_version) output << "Operating System: #{err.osname} #{err.major_version}" end output << "Framework: #{err.framework}" if err.respond_to?(:framework) output << "Puppet Module: #{err.module_name}" if err.respond_to?(:module_name) output << "Original Error Type: #{err.original_error.class}" if err.respond_to?(:original_error) output << "Backtrace:\n\t\t#{err.backtrace.join("\n\t\t")}\n" AbideDevUtils::Output.simple(output.join("\n\t"), stream: $stderr) end warnings.each do |err| output = ["[warn]: #{err.}"] # Errors should all be instances of AbideDevUtils::Errors::BenchmarkLoadError # We check that the extra methods on this error are valid before calling them, though, because # other errors might be returned somehow. if err.respond_to?(:osname) && err.respond_to?(:major_version) output << "Operating System: #{err.osname} #{err.major_version}" end output << "Framework: #{err.framework}" if err.respond_to?(:framework) output << "Puppet Module: #{err.module_name}" if err.respond_to?(:module_name) AbideDevUtils::Output.simple(output.join("\n\t"), stream: $stderr) end exit 1 unless errors.empty? end |