module Cane::CLI
Command line interface. This passes off arguments to the parser and starts the Cane
runner
Default options for command line interface
Public Class Methods
default_options()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
default_options()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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