Class: Boxes::Command::Build
- Inherits:
-
Boxes::Command
- Object
- CLAide::Command
- Boxes::Command
- Boxes::Command::Build
- Defined in:
- lib/boxes/command/build.rb
Overview
Command handling for the box building functionality.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Build
constructor
A new instance of Build.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Build
Returns a new instance of Build.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/boxes/command/build.rb', line 18 def initialize(argv) @build = {} @build[:name] = argv.option('name') @build[:provider] = argv.option('provider') @build[:template] = argv.option('template') scripts = argv.option('scripts') || '' @build[:scripts] = scripts.split(',') super end |
Class Method Details
.options ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/boxes/command/build.rb', line 8 def self. [ ['--name', 'The name for the build'], ['--provider=[virtualbox|vmware]', 'The provider to build the box for'], ['--template', 'Template to build the box with'], ['--scripts', 'Scripts to apply to the box'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/boxes/command/build.rb', line 37 def run env = Boxes::Environment.new builder = Boxes::Builder.new(env, @build) builder.run builder.clean rescue Boxes::Errors::BuildRunError => e puts "[!] #{e}".red exit 1 end |
#validate! ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/boxes/command/build.rb', line 29 def validate! super %w(name provider template).each do |key| help! "A #{key} is required!" if @build[key.to_sym].nil? end end |