Module: Cane::CLI

Defined in:
lib/cane/cli.rb,
lib/cane/cli/parser.rb,
lib/cane/cli/options.rb

Overview

Default options for command line interface

Defined Under Namespace

Classes: Parser

Class Method Summary collapse

Class Method Details

.default_optionsObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/cane/cli/options.rb', line 18

def default_options
  {
    max_violations:  0,
    parallel:        false,
    exclusions_file: nil,
    checks:          Cane.default_checks
  }.merge(Cane.default_checks.inject({}) {|a, check|
    a.merge(defaults(check))
  })
end

.defaults(check) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/cane/cli/options.rb', line 6

def defaults(check)
  check.options.each_with_object({}) {|(k, v), h|
    option_opts = v[1] || {}
    if option_opts[:type] == Array
      h[k] = []
    else
      h[k] = option_opts[:default]
    end
  }
end

.run(args) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/cane/cli.rb', line 10

def run(args)
  spec = Parser.parse(args)
  if spec.is_a?(Hash)
    Cane.run(spec)
  else
    spec
  end
end