-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.rb
32 lines (25 loc) · 933 Bytes
/
parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Parse ARGV options and return a OpenStruct with it.
class Parser
def self.parse(args)
options = OpenStruct.new
options.template = '- {{url}} <!-- {{branch}} -->'
options.base_branches = ['master']
options.open_only = false
options.debug = false
OptionParser.new do |opt|
opt.on('-b', '--base-branches [BRANCH1[,BRANCH2...]]') do |base_branches|
options.base_branches = base_branches.split(',') if base_branches
end
opt.on('-t', '--template [TEMPLATE]', 'Example: \'- {{url}} <!-- {{branch}} -->\' | Available variables: url, branch') do |templates|
options.template = templates if templates
end
opt.on('-o', '--open-only', 'When set, show only open pull requests') do |open_only|
options.open_only = open_only
end
opt.on('-d', '--debug') do |debug|
options.debug = debug
end
end.parse!(args)
options
end
end