Class: VagrantPlugins::DevCommands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/devcommands/command.rb

Overview

Defines the executable vagrant command

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, env) ⇒ Command



9
10
11
12
13
# File 'lib/vagrant/devcommands/command.rb', line 9

def initialize(argv, env)
  @registry = Registry.new

  super(argv, env)
end

Class Method Details

.synopsisObject



5
6
7
# File 'lib/vagrant/devcommands/command.rb', line 5

def self.synopsis
  'runs vagrant commands from a Commandfile'
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant/devcommands/command.rb', line 15

def execute
  command     = @argv.last
  commandfile = Commandfile.new(@env)

  return display_error('Missing "Commandfile"') unless commandfile.exist?

  @registry.read_commandfile(commandfile)

  return display_help unless command

  unless @registry.valid_command?(command)
    return display_error("Invalid command \"#{command}\"\n")
  end

  run @registry.commands[command]
end