Class: Rome::Options

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

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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
# File 'lib/rome.rb', line 14

def self.parse(args)
  options = {}

  OptionParser.new do |opts|
    opts.program_name = File.basename(bash)
    opts.banner = "Usage: #{opts.program_name} [options]"

    opts.separator ""
    opts.separator "Options:"

    opts.on("-oNAME", "--output=NAME", "Specify output file name") do |v|
      options[:output] = v
    end

    opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
      options[:verbose] = v
    end

    opts.on_tail("-h", "--help", "Print help", "something else") do |v|
      abort opts.to_s
    end

    opts.on_tail("-V", "--version", "Print version") do |v|
      abort "#{opts.program_name} #{VERSION}"
    end
  end.parse!(args)

  options
end