Class: VagrantPlugins::DevCommands::CommandDef
- Inherits:
-
Object
- Object
- VagrantPlugins::DevCommands::CommandDef
- Defined in:
- lib/vagrant/devcommands/command_def.rb
Overview
Definition of an executable command
Instance Attribute Summary collapse
-
#box ⇒ Object
readonly
Returns the value of attribute box.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#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) ⇒ CommandDef
constructor
A new instance of CommandDef.
- #run_script(argv) ⇒ Object
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
#box ⇒ Object (readonly)
Returns the value of attribute box.
11 12 13 |
# File 'lib/vagrant/devcommands/command_def.rb', line 11 def box @box end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
12 13 14 |
# File 'lib/vagrant/devcommands/command_def.rb', line 12 def desc @desc end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
13 14 15 |
# File 'lib/vagrant/devcommands/command_def.rb', line 13 def help @help end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/vagrant/devcommands/command_def.rb', line 7 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/vagrant/devcommands/command_def.rb', line 8 def parameters @parameters end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
9 10 11 |
# File 'lib/vagrant/devcommands/command_def.rb', line 9 def script @script end |
#usage ⇒ Object (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 |