class Optparse

Public Class Methods

parse(args) click to toggle source
# File lib/web-puc.rb, line 17
def self.parse(args)
  options = OpenStruct.new
  options.exclude = []
  options.libs = []
  options.clear = 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('-c', '--clear', 'Clear cached version data') do
      options.clear = 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('-l', '--libs GLOB', Array, 'libs to search') do |list|
      options.libs = list
    end

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

  opt_parser.parse!(args)
  options
end