Class: RuboCop::Daemon::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/daemon/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new_parser(&_block) ⇒ Object



8
9
10
11
12
13
# File 'lib/rubocop/daemon/cli.rb', line 8

def self.new_parser(&_block)
  OptionParser.new do |opts|
    opts.version = VERSION
    yield(opts)
  end
end

Instance Method Details

#parserObject



28
29
30
31
32
# File 'lib/rubocop/daemon/cli.rb', line 28

def parser
  @parser ||= self.class.new_parser do |opts|
    opts.banner = 'usage: rubocop-daemon <command> [<args>]'
  end
end

#run(argv = ARGV) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubocop/daemon/cli.rb', line 15

def run(argv = ARGV)
  parser.order!(argv)
  return if argv.empty?

  create_subcommand_instance(argv)
rescue OptionParser::InvalidOption => e
  warn "error: #{e.message}"
  exit 1
rescue UnknownClientCommandError => e
  warn "rubocop-daemon: #{e.message}. See 'rubocop-daemon --help'."
  exit 1
end