Module: Protobox::Commands
Constant Summary collapse
- STOCK_COMMANDS =
%w[install switch]
- CUSTOM_COMMANDS =
%w[init]
Instance Method Summary collapse
-
#help(args) ⇒ Object
$ protobox help.
-
#init(args) ⇒ Object
$ protobox init.
-
#pass(args) ⇒ Object
pass through.
- #run(args) ⇒ Object
-
#version(args) ⇒ Object
$ protobox version.
Instance Method Details
#help(args) ⇒ Object
$ protobox help
42 43 44 45 |
# File 'lib/protobox/commands.rb', line 42 def help(args) require_relative 'command/help' Command::Help.execute(args) end |
#init(args) ⇒ Object
$ protobox init
36 37 38 39 |
# File 'lib/protobox/commands.rb', line 36 def init(args) require_relative 'command/init' Command::Init.execute(args) end |
#pass(args) ⇒ Object
pass through
53 54 55 56 |
# File 'lib/protobox/commands.rb', line 53 def pass(args) require_relative 'command/passthrough' Command::PassThrough.execute(args) end |
#run(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/protobox/commands.rb', line 8 def run(args) args.unshift 'help' if args.empty? # get first argument cmd = args[0] # commands can have dashes cmd = cmd.gsub(/(\w)-/, '\1_') if STOCK_COMMANDS.include?(cmd) send("pass", args) elsif method_defined?(cmd) and cmd != 'run' and cmd != 'pass' args.shift send(cmd, args) else send("help", args) end rescue Errno::ENOENT if $!..include? "No such file or directory - vagrant" abort "Error: `vagrant` command not found" else raise end rescue Errors::Error => err abort "Error: #{err.}" end |