Class: PuppetCheck::CLI
- Inherits:
-
Object
- Object
- PuppetCheck::CLI
- Defined in:
- lib/puppet-check/cli.rb
Overview
the command line interface for PuppetCheck
Class Method Summary collapse
-
.parse(args) ⇒ Object
parse the user arguments.
-
.run(args) ⇒ Object
run method for the cli.
Class Method Details
.parse(args) ⇒ Object
parse the user arguments
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet-check/cli.rb', line 17 def self.parse(args) opt_parser = OptionParser.new do |opts| # usage opts. = 'usage: puppet-check [options] paths' # base options opts.on('--version', 'Display the current version.') do puts 'puppet-check 1.3.1' exit 0 end # bool options opts.on('-f', '--future', 'Enable future parser') { PuppetCheck.future_parser = true } opts.on('-s', '--style', 'Enable style checks') { PuppetCheck.style_check = true } # formatting options opts.on('-o', '--output format', String, 'Format for results output (default is text): text, json, or yaml') { |arg| PuppetCheck.output_format = arg } # arguments to style checkers opts.on('--puppet-lint arg_one,arg_two', Array, 'Arguments for PuppetLint ignored checks') do |puppetlint_args| PuppetCheck.puppetlint_args += puppetlint_args.map { |arg| "--#{arg}" } end opts.on('-c', '--config file', String, 'Load PuppetLint options from file.') do |file| PuppetCheck.puppetlint_args += File.read(file).split("\n") end opts.on('--rubocop arg_one,arg_two', String, 'Arguments for Rubocop disabled cops') { |arg| PuppetCheck.rubocop_args = ['--except', arg] } end opt_parser.parse!(args) end |
.run(args) ⇒ Object
run method for the cli
7 8 9 10 11 12 13 14 |
# File 'lib/puppet-check/cli.rb', line 7 def self.run(args) # gather the user arguments parse(args) raise 'puppet-check: no paths specified' if args.empty? # run PuppetCheck PuppetCheck.new.run(args) end |