Module: Management
- Defined in:
- lib/management/helper.rb,
lib/management/command.rb,
lib/management/version.rb,
lib/management/interpreter.rb,
lib/management/commands/server/run.rb,
lib/management/commands/server/ssh.rb,
lib/management/commands/server/list.rb,
lib/management/commands/server/stop.rb,
lib/management/commands/address/list.rb,
lib/management/commands/server/start.rb,
lib/management/commands/server/create.rb,
lib/management/commands/address/attach.rb,
lib/management/commands/server/console.rb,
lib/management/commands/server/destroy.rb
Defined Under Namespace
Modules: Address, Helper, Server Classes: Command
Constant Summary collapse
- VERSION =
"1.4"
Class Method Summary collapse
Class Method Details
.interpret!(argv) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/management/interpreter.rb', line 3 def self.interpret!(argv) require 'optparse' commands = Management::Command.all parser = OptionParser.new do |opts| opts. = "Usage: management [command [arg ...]]" opts.separator('') opts.separator('Commands:') commands.each { |command| opts.separator command.help_string } opts.separator('') opts.on('-h', '--help', 'Display this screen') { abort opts.to_s } opts.on('-v', '--version', 'Show version') { abort Management::VERSION } end abort parser.help if argv.empty? error_handler = lambda { |e| abort "Error: #{e}\n\n" + parser.help } args = parser.parse(argv) task = args.shift command = commands.find{|c|c.command_name == task} error_handler.call "unknown task \"#{task}\"" if command.nil? command.call_with(args, error_handler) end |