Class: Vagrant::Node::Command
- Inherits:
-
Object
- Object
- Vagrant::Node::Command
- Defined in:
- lib/vagrant-node/nodeservercommand.rb
Constant Summary collapse
- START_COMMAND =
"start"- STOP_COMMAND =
"stop"
Instance Method Summary collapse
- #execute ⇒ Object
- #help ⇒ Object
-
#initialize(argv, env) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(argv, env) ⇒ Command
Returns a new instance of Command.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-node/nodeservercommand.rb', line 11 def initialize(argv, env) super @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv) @subcommands = Vagrant::Registry.new @subcommands.register(:start) do require File.("../nodeserverstart", __FILE__) NodeServerStart end @subcommands.register(:stop) do require File.("../nodeserverstop", __FILE__) NodeServerStop end @subcommands.register(:passwd) do require File.("../nodeserverpasswd", __FILE__) NodeServerPasswd end end |
Instance Method Details
#execute ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-node/nodeservercommand.rb', line 34 def execute if @main_args.include?("-h") || @main_args.include?("--help") # Print help return help end command_class = @subcommands.get(@sub_command.to_sym) if @sub_command return help if !command_class || !@sub_command @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}") command_class.new(@sub_args, @env).execute 0 end |
#help ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vagrant-node/nodeservercommand.rb', line 51 def help opts = OptionParser.new do |opts| opts. = "Usage: vagrant nodeserver <command>" opts.separator "" opts.on("-h", "--help", "Print this help.") opts.separator "" opts.separator "Available subcommands:" opts.separator " start" opts.separator " stop" opts.separator " passwd" opts.separator "" end @env.ui.info(opts.help, :prefix => false) end |