Class: DMAMP::Opts

Inherits:
Object
  • Object
show all
Defined in:
lib/dmamp/optionparser.rb

Overview

Option parsing class, all options available via the options accessor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOpts

Parses options from ARGV



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
# File 'lib/dmamp/optionparser.rb', line 11

def initialize
  @options = DEFAULTARGS
  op = OptionParser.new do |opts|
    opts.banner = "Usage: dmamp [options] MODULENAME"
  
    opts.on("-p", "--parameters [PARAMS]", String, "Comma seperated list of additional parameter names (default is none)") do |p|
      @options[:parameters] = p.gsub(/ /, "").split(",") if p
    end
    opts.on("-P", "--pattern [PATTERN]", String, "Module pattern to used (defaults to parameterised-PCS)") do |p|
      @options[:pattern] = p if p
    end
    opts.on("-v", "--version") do |v|
      if v
        puts VERSION
        exit 0
      end
    end

  end
  op.parse!
  raise OptionParser::MissingArgument unless ARGV[0]
  @options[:modulename] = ARGV[0]
rescue OptionParser::MissingArgument
  puts op
  abort "Arguments required"
end

Instance Attribute Details

#optionsObject

Parsed option hash



8
9
10
# File 'lib/dmamp/optionparser.rb', line 8

def options
  @options
end