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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/git_pissed/options.rb', line 28
def parse!
options = OptionParser.new do |opts|
opts.banner = [
'usage: git-pissed',
'[--words=<array>]',
'[--max-revisions=<integer>]',
"[--format=<#{FORMATS.join('|')}>]",
'[--version]'
].join(' ')
opts.separator "\noptions:"
opts.on(
"--words=#{DEFAULT_WORDS.join(',')}", Array,
'Words to track across entire history'
) do |words|
raise OptionParser::InvalidArgument if words.empty?
@words = words
end
opts.on(
"--max-revisions=#{MAX_REVISIONS}", Integer,
'Number of revisions to track, spread equally across entire history'
) do |max_revisions|
@max_revisions = max_revisions
end
opts.on(
"--format=#{FORMATS.first}", String,
"Output format. Supported formats: #{FORMATS.join(', ')}"
) do |format|
raise OptionParser::InvalidArgument unless FORMATS.include?(format)
@format = format
end
opts.on('--version', 'Show version') do
puts VERSION
exit
end
end
options.parse!
self
rescue OptionParser::MissingArgument, OptionParser::InvalidArgument
abort options.help
end
|