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
|
# File 'lib/recheck/cli.rb', line 20
def run
global_options = Recheck::Optimist.options(@argv) do
version "recheck v#{Recheck::VERSION}"
banner "Usage:"
banner " recheck [global options] [<command> [options]]"
banner "\nGlobal options:"
opt :version, "Print version and exit", short: :v
opt :help, "Print help", short: :h
stop_on COMMANDS.keys.map(&:to_s)
banner "\nCommands:"
COMMANDS.each { |c, desc| banner format(" %-10s %s", c, desc) }
end
command = global_options[:_leftovers].shift&.to_sym || :help
Recheck::Optimist.die "unknown command '#{command}'" unless COMMANDS.include? command
Recheck::Command.const_get(command.to_s.split("_").map(&:capitalize).join("")).new(argv: global_options[:_leftovers]).run
exit EXIT_CODE[:no_errors]
rescue Interrupt
puts "\nOperation cancelled by user."
exit EXIT_CODE[:recheck_error]
end
|