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
-
#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.
-
#tty ⇒ Object
readonly
Returns the value of attribute tty.
-
#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.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant/devcommands/model/command.rb', line 20 def initialize(spec) @name = spec[:name] @flags = spec[:flags] || {} @parameters = spec[:parameters] || {} @script = spec[:script] @tty = spec[:tty] == true @machine = spec[:machine] @desc = spec[:desc] @help = spec[:help] @usage = spec[:usage] end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
16 17 18 |
# File 'lib/vagrant/devcommands/model/command.rb', line 16 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.
17 18 19 |
# File 'lib/vagrant/devcommands/model/command.rb', line 17 def help @help end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
15 16 17 |
# File 'lib/vagrant/devcommands/model/command.rb', line 15 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 |
#tty ⇒ Object (readonly)
Returns the value of attribute tty.
13 14 15 |
# File 'lib/vagrant/devcommands/model/command.rb', line 13 def tty @tty end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
18 19 20 |
# File 'lib/vagrant/devcommands/model/command.rb', line 18 def usage @usage end |
Instance Method Details
#run_script(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant/devcommands/model/command.rb', line 34 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 |