Class: Ardb::CLI
- Inherits:
-
Object
- Object
- Ardb::CLI
- Defined in:
- lib/ardb/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run(*args) ⇒ Object
Constructor Details
#initialize ⇒ CLI
12 13 14 |
# File 'lib/ardb/cli.rb', line 12 def initialize @cli = CLIRB.new end |
Class Method Details
.run(*args) ⇒ Object
8 9 10 |
# File 'lib/ardb/cli.rb', line 8 def self.run(*args) self.new.run(*args) end |
Instance Method Details
#help ⇒ Object
45 46 47 48 49 50 |
# File 'lib/ardb/cli.rb', line 45 def help "Usage: ardb [options] COMMAND\n"\ "\n"\ "Options:"\ "#{@cli}" end |
#run(*args) ⇒ Object
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 |
# File 'lib/ardb/cli.rb', line 16 def run(*args) begin @cli.parse!(args) Ardb::Runner.new(@cli.args, @cli.opts).run rescue CLIRB::HelpExit puts help rescue CLIRB::VersionExit puts Ardb::VERSION rescue Ardb::Runner::UnknownCmdError => err $stderr.puts "#{err.message}\n\n" $stderr.puts help exit(1) rescue Ardb::NotConfiguredError, Ardb::Runner::CmdError => err $stderr.puts "#{err.message}" exit(1) rescue Ardb::Runner::CmdFail => err exit(1) rescue CLIRB::Error => exception $stderr.puts "#{exception.message}\n\n" $stderr.puts help exit(1) rescue Exception => exception $stderr.puts "#{exception.class}: #{exception.message}" $stderr.puts exception.backtrace.join("\n") exit(1) end exit(0) end |