Class: Optparse

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

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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

def self.parse(args)
  options = OpenStruct.new
  options.exclude = []
  options.libs = []
  options.clear = 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('-c', '--clear', 'Clear cached version data') do
      options.clear = true
    end

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

    opts.on('-l', '--libs GLOB', Array, 'libs to search') do |list|
      options.libs = list
    end

    # TODO: make this work
    #opts.on('-v', '--version', 'Show version') do
    #  puts Gem::Specification::load(File.expand_path('../web-puc.gemspec', __FILE__)).version
    #  exit
    #end

  end

  opt_parser.parse!(args)
  options
end