module Aladdin::Commands
Parses the command line arguments and invokes the relevant command. @example Adding a command
Commands.register do def new # do stuff end end
Constants
- USAGE
Path to
USAGE
file.
Public Instance Methods
parse!(argv=ARGV, opts={})
click to toggle source
Parses the command line arguments.
# File lib/aladdin/commands.rb, line 26 def parse!(argv=ARGV, opts={}) command = argv.shift case command when '--version', '-v' puts "Aladdin #{Aladdin::VERSION}" exit 0 when nil, '--help', '-h' puts File.read USAGE exit 0 else require_relative 'commands/new' require_relative 'commands/server' send command, argv, opts end rescue => e puts e.message puts File.read USAGE exit 1 end
register(&block)
click to toggle source
Registers a new command.
# File lib/aladdin/commands.rb, line 21 def register(&block) extend Module.new(&block) end