Class: Vbuilder::Generator::Options
- Inherits:
-
Hash
- Object
- Hash
- Vbuilder::Generator::Options
- Defined in:
- lib/vbuilder/generator/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#orig_args ⇒ Object
Returns the value of attribute orig_args.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #merge(other) ⇒ Object
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vbuilder/generator/options.rb', line 9 def initialize(args) super() @orig_args = args.clone @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options]\ne.g. #{File.basename($0)} --provider aws" o.on('-v', '--version', 'show ruby gem version') do |ver| puts "Version: #{Vbuilder::Version.version}" exit end o.on('-P', '--providers', 'see the list of valid providers') do puts "Valid providers:" Vbuilder::Helper::Utility.get_provider_list.each do |provider| puts " - #{provider}" end exit end o.on('-i', '--interactive', 'choose to interactively fill these config attributes out on the CLI') do self[:interactive] = true end o.on('-p', '--provider [PROVIDER]', 'specify the provider to use in the building of your Vagrantfile') do |provider| unless provider.nil? self[:provider] = provider else self[:invalid_argument] = "please specify a provider" end end o.separator "" end begin @opts.parse!(args) rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. end def merge(other) self.class.new(@orig_args + other.orig_args) end end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
7 8 9 |
# File 'lib/vbuilder/generator/options.rb', line 7 def opts @opts end |
#orig_args ⇒ Object
Returns the value of attribute orig_args.
7 8 9 |
# File 'lib/vbuilder/generator/options.rb', line 7 def orig_args @orig_args end |
Instance Method Details
#merge(other) ⇒ Object
52 53 54 |
# File 'lib/vbuilder/generator/options.rb', line 52 def merge(other) self.class.new(@orig_args + other.orig_args) end |