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
53
54
|
# File 'lib/jira_diff/options.rb', line 17
def self.parse(argv_opts = [], unit_testing = false)
opt_parse = DevTools::OptParse.new({ name: PROGRAM_NAME,
version: VERSION,
testing: unit_testing,
defaults: default_options })
parser = opt_parse.parser
parser.banner = "Usage: #{DevTools::PROGRAM} [OPTIONS]"
parser.separator ""
parser.separator "[OPTIONS]"
parser.separator ""
parser.separator "Specific Options:"
parser.on("-d", "--directory DIR", "Use DIR as our source directory") do |dir|
dir = File.expand_path(dir.strip)
if Dir.exist?(dir)
Options.directory = dir
else
raise ArgumentError, "ENOEXIST: Directory does not exist -> #{dir}"
end
end
parser.on("-m", "--master BRANCH", "Specify a master branch (default: master)") { |m| Options.master = m }
parser.on("-s", "--source BRANCH",
"Use BRANCH as the source to compare against (may be used more than once)") do |branch|
Options.source << branch unless Options.source.include?(branch)
end
parser.separator ""
parser.separator "Common Options:"
parser.parse!(argv_opts)
validate_options(Options)
end
|