Class: VagrantPlugins::DevCommands::CommandDef

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

Overview

Definition of an executable command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ CommandDef



16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant/devcommands/command_def.rb', line 16

def initialize(spec)
  @name       = spec[:name]
  @parameters = spec[:parameters]
  @script     = spec[:script]

  @box   = spec[:box]
  @desc  = spec[:desc]
  @help  = spec[:help]
  @usage = spec[:usage]
end

Instance Attribute Details

#boxObject (readonly)

Returns the value of attribute box.



11
12
13
# File 'lib/vagrant/devcommands/command_def.rb', line 11

def box
  @box
end

#descObject (readonly)

Returns the value of attribute desc.



12
13
14
# File 'lib/vagrant/devcommands/command_def.rb', line 12

def desc
  @desc
end

#helpObject (readonly)

Returns the value of attribute help.



13
14
15
# File 'lib/vagrant/devcommands/command_def.rb', line 13

def help
  @help
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/vagrant/devcommands/command_def.rb', line 7

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



8
9
10
# File 'lib/vagrant/devcommands/command_def.rb', line 8

def parameters
  @parameters
end

#scriptObject (readonly)

Returns the value of attribute script.



9
10
11
# File 'lib/vagrant/devcommands/command_def.rb', line 9

def script
  @script
end

#usageObject (readonly)

Returns the value of attribute usage.



14
15
16
# File 'lib/vagrant/devcommands/command_def.rb', line 14

def usage
  @usage
end

Instance Method Details

#run_script(argv) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/vagrant/devcommands/command_def.rb', line 27

def run_script(argv)
  script = @script
  script = script.call if script.is_a?(Proc)

  opts = {}
  opts = parse_argv(argv) if @parameters

  (script % opts).strip
end