Class: VagrantPlugins::DevCommands::Model::Command
- Inherits:
-
Object
- Object
- VagrantPlugins::DevCommands::Model::Command
- Defined in:
- lib/vagrant/devcommands/model/command.rb
Overview
Definition of an executable command
Instance Attribute Summary collapse
-
#deprecated_box_config ⇒ Object
readonly
Returns the value of attribute deprecated_box_config.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(spec) ⇒ Command
constructor
A new instance of Command.
- #run_script(argv) ⇒ Object
Constructor Details
#initialize(spec) ⇒ Command
Returns a new instance of Command.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant/devcommands/model/command.rb', line 21 def initialize(spec) @name = spec[:name] @flags = spec[:flags] || {} @parameters = spec[:parameters] || {} @script = spec[:script] @machine = spec[:machine] || spec[:box] @desc = spec[:desc] @help = spec[:help] @usage = spec[:usage] @deprecated_box_config = spec.key?(:box) end |
Instance Attribute Details
#deprecated_box_config ⇒ Object (readonly)
Returns the value of attribute deprecated_box_config.
19 20 21 |
# File 'lib/vagrant/devcommands/model/command.rb', line 19 def deprecated_box_config @deprecated_box_config end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
15 16 17 |
# File 'lib/vagrant/devcommands/model/command.rb', line 15 def desc @desc end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def flags @flags end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
16 17 18 |
# File 'lib/vagrant/devcommands/model/command.rb', line 16 def help @help end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
14 15 16 |
# File 'lib/vagrant/devcommands/model/command.rb', line 14 def machine @machine end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/vagrant/devcommands/model/command.rb', line 8 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
11 12 13 |
# File 'lib/vagrant/devcommands/model/command.rb', line 11 def parameters @parameters end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
12 13 14 |
# File 'lib/vagrant/devcommands/model/command.rb', line 12 def script @script end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
17 18 19 |
# File 'lib/vagrant/devcommands/model/command.rb', line 17 def usage @usage end |
Instance Method Details
#run_script(argv) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/vagrant/devcommands/model/command.rb', line 36 def run_script(argv) script = @script script = script.call if script.is_a?(Proc) opts = {} opts = parse_argv(argv) unless @flags.empty? && @parameters.empty? (script % opts).strip end |