13
14
15
16
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
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/rubocop/service/cli.rb', line 13
def run(argv)
parser = OptionParser.new
parser.program_name = "rubocop-service"
parser.version = VERSION
command "install", "Patch the rubocop." do
RuboCop::Service::Installer.new.run
end
command "uninstall", "Unpatch the rubocop." do
RuboCop::Service::Uninstaller.new.run
end
command "start", "Start the manager server." do
RuboCop::Service::Server.start
end
command "stop", "Stop the manager server." do
RuboCop::Service::Server.stop
end
command "status", "Show status of the manager server." do
RuboCop::Service::Server.status
end
command nil do
puts parser.help
end
parser.banner = +<<~BANNER
Usage: rubocop-service [options] [command]
Commands:
BANNER
@commands.each do |command, (desc, _block)|
next unless desc
parser.banner << " #{command} - #{desc}\n"
end
parser.separator ""
parser.separator "Options:"
parser.on("-v", "--verbose", "Verbose output") do |verb|
@options[:verbose] = verb
end
parser.parse! argv
ENV["RUBOCOP_SERVICE_VERBOSE"] = "true" if @options[:verbose]
@commands[argv.first] ? @commands[argv.first].last.call : @commands[nil].last.call
end
|