class Rubocop::Changes::Options
Constants
- Options
Attributes
args[R]
Public Class Methods
new()
click to toggle source
# File lib/rubocop/changes/options.rb, line 10 def initialize @args = Options.new(:simple, false, nil, false) # Defaults end
Public Instance Methods
parse!()
click to toggle source
# File lib/rubocop/changes/options.rb, line 14 def parse! OptionParser.new do |opts| opts.banner = 'Usage: rubocop-changes [options]' parse_formatter!(opts) parse_commit!(opts) parse_quiet!(opts) parse_auto_correct!(opts) parse_help!(opts) parse_version!(opts) end.parse! args end
Private Instance Methods
formatter_values()
click to toggle source
# File lib/rubocop/changes/options.rb, line 33 def formatter_values formatters = RuboCop::Formatter::FormatterSet::BUILTIN_FORMATTERS_FOR_KEYS formatters.keys.map do |key| key.gsub(/[\[\]]/, '').to_sym end end
parse_auto_correct!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 68 def parse_auto_correct!(opts) opts.on('-a', '--auto-correct', 'Auto correct errors') do |v| args.auto_correct = v end end
parse_commit!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 52 def parse_commit!(opts) opts.on( '-c', '--commit [COMMIT_ID]', 'Compare from some specific point on git history' ) do |c| args.commit = c end end
parse_formatter!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 41 def parse_formatter!(opts) opts.on( '-f', '--formatter [FORMATER]', formatter_values, "Select format type (#{formatter_values.join(', ')})" ) do |t| args.format = t end end
parse_help!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 74 def parse_help!(opts) opts.on('-h', '--help', 'Prints this help') do puts opts exit end end
parse_quiet!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 62 def parse_quiet!(opts) opts.on('-q', '--quiet', 'Be quiet') do |v| args.quiet = v end end
parse_version!(opts)
click to toggle source
# File lib/rubocop/changes/options.rb, line 81 def parse_version!(opts) opts.on('--version', 'Display version') do puts Rubocop::Changes::VERSION exit 0 end end