Class: ArgParser

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

Class Method Summary collapse

Class Method Details

.parse(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/arg_parser.rb', line 5

def self.parse(options)
  args = OpenStruct.new

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: grspec [git ref] [git ref] [options]"

    opts.on("-rSPEC_REGEX", "--regex=SPEC_REGEX", Regexp, "Regex to filter specs") do |regex|
      args.spec_regex = regex
    end

    opts.on("-d", "--dry", "Performs a dry run for a listing that would be passed through to RSpec") do
      args.dry_run = true
    end

    opts.on("-h", "--help", "Prints this help") do
      puts opts
      exit
    end
  end

  opt_parser.parse!(options)

  args
end