Class: Messiah::Generator::Options
- Inherits:
-
Hash
- Object
- Hash
- Messiah::Generator::Options
- Defined in:
- lib/messiah/generator/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
6 7 8 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 |
# File 'lib/messiah/generator/options.rb', line 6 def initialize(args) super() @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} options\ne.g. #{File.basename($0)} --rspec --cucumber" o.on('--rspec', 'generate rspec support files') do self[:rspec] = true end o.on('--cucumber', 'generate cucumber support files') do self[:cucumber] = true end o.on('--testunit', 'generate testunit support files') do self[:testunit] = true end o.separator "" o.on_tail('-h', '--help', 'display this help and exit') do self[:show_help] = true end end begin @opts.parse!(args) self[:directory] = args.shift || Dir.pwd rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. end end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/messiah/generator/options.rb', line 4 def opts @opts end |