Class: Mercury::CLI::Base
- Inherits:
-
Cri::Base
- Object
- Cri::Base
- Mercury::CLI::Base
- Defined in:
- lib/mercury/cli/base.rb
Instance Method Summary collapse
-
#global_option_definitions ⇒ Object
Returns the list of global option definitionss.
- #handle_option(option) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mercury/cli/base.rb', line 20 def initialize super('mercury') # Add help command self.help_command = Mercury::CLI::Commands::Help.new add_command(self.help_command) # Add other commands add_command(Mercury::CLI::Commands::Show.new) end |
Instance Method Details
#global_option_definitions ⇒ Object
Returns the list of global option definitionss.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mercury/cli/base.rb', line 32 def global_option_definitions [ { :long => 'help', :short => 'h', :argument => :forbidden, :desc => 'show this help message and quit' }, { :long => 'no-color', :short => 'C', :argument => :forbidden, :desc => 'disable color' }, { :long => 'version', :short => 'v', :argument => :forbidden, :desc => 'show version information and quit' }, { :long => 'verbose', :short => 'V', :argument => :forbidden, :desc => 'make mercury output more detailed' } ] end |
#handle_option(option) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mercury/cli/base.rb', line 53 def handle_option(option) # Handle version option if option == :version puts "Mercury Bootstrap Client #{Mercury::VERSION} (c) 2011 David Love." puts "Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) running on #{RUBY_PLATFORM}" exit 0 # Handle verbose option elsif option == :verbose Mercury::CLI::Logger.instance.level = :low # Handle no-color option elsif option == :'no-color' Mercury::CLI::Logger.instance.color = false # Handle help option elsif option == :help show_help exit 0 end end |