Class: Optparse

Inherits:
Object
  • Object
show all
Defined in:
lib/web-puc.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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
# File 'lib/web-puc.rb', line 9

def self.parse(args)
  options = OpenStruct.new
  options.exclude = []
  options.update = false
  options.stat = false

  opt_parser = OptionParser.new do |opts|
    opts.banner = 'Usage: web-puc [options] <files>'

    opts.on('-e', '--exclude GLOB', Array, 'Exclude from consideration all files matching GLOB') do |list|
      options.exclude = list
    end

    opts.on('-s', '--allow-supported', 'Allow supported versions even if not latest') do
    end

    opts.on('-u', '--update', 'Update web package database') do
      options.update = true
    end

    opts.on('--stat', 'Output in STAT format') do
      options.stat = true
    end

    opts.on('-h', '--help', 'Show this message') do
      puts opts
      exit
    end

    opts.on_tail('-v', '--version', 'Show version') do
      puts "web-puc #{WebPuc::VERSION}"
      exit
    end
  end

  opt_parser.parse!(args)
  options
end