Class: PEBuild::Command

Inherits:
Vagrant::Command::Base
  • Object
show all
Defined in:
lib/pe_build/command.rb

Defined Under Namespace

Classes: Download, List

Instance Method Summary collapse

Constructor Details

#initialize(argv, env) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pe_build/command.rb', line 5

def initialize(argv, env)
  @argv, @env = argv, env

  @main_args, @subcommand, @sub_args = split_main_and_subcommand(argv)

  # Is this even remotely sane? Are we verging on cargo cult programming?
  @subcommands = Vagrant::Registry.new

  @subcommands.register('download') { PEBuild::Command::Download }
  @subcommands.register('list')     { PEBuild::Command::List }
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
# File 'lib/pe_build/command.rb', line 17

def execute
  if @subcommand and (klass = @subcommands.get(@subcommand))
    klass.new(@argv, @env).execute
  elsif @subcommand
    raise "Unrecognized subcommand #{@subcommand}"
  else
    PEBuild::Command::List.new(@argv, @env).execute
  end
end