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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/reapack/index/cli/options.rb', line 44
def parse_options(args, basepath = nil)
opts = Hash.new
OptionParser.new do |op|
op.program_name = PROGRAM_NAME
op.version = ReaPack::Index::VERSION
op.banner = "Package indexer for git-based ReaPack repositories\n" +
"Usage: #{PROGRAM_NAME} [options] [directory]"
op.separator 'Modes:'
op.on '-c', '--check', 'Test every package including uncommited changes and exit' do
opts[:check] = true
end
op.on '-s', '--scan [PATH|COMMIT]', 'Scan new commits (default), a path or a specific commit' do |commit|
opts[:check] = opts[:rebuild] = false
opts[:scan] ||= []
if commit
opts[:scan] << expand_path(commit.strip, base: basepath, relative: true)
else
opts[:scan].clear
end
end
op.on '--no-scan', 'Do not scan for new commits' do
opts[:scan] = false
end
op.on '--rebuild', 'Clear the index and rescan the whole git history' do
opts[:check] = false
opts[:rebuild] = true
end
op.separator 'Indexer options:'
op.on '-a', '--[no-]amend', 'Update existing versions' do |bool|
opts[:amend] = bool
end
op.on '-i', '--ignore PATH', "Don't check or index any file starting with PATH" do |path|
opts[:ignore] ||= []
opts[:ignore] << expand_path(path, base: basepath)
end
op.on '-o', "--output FILE=#{DEFAULTS[:output]}",
'Set the output filename and path for the index' do |file|
opts[:output] = expand_path(file.strip, base: basepath, relative: true)
end
op.on '--[no-]strict', 'Enable strict validation mode' do |bool|
opts[:strict] = bool
end
op.on '-U', "--url-template TEMPLATE=#{DEFAULTS[:url_template]}",
'Set the template for implicit download links' do |tpl|
opts[:url_template] = tpl.strip
end
op.separator 'Repository metadata:'
op.on '-n', '--name NAME', 'Set the name shown in ReaPack for this repository' do |name|
opts[:name] = name.strip
end
op.on '-l', '--link LINK', 'Add or remove a website link' do |link|
opts[:links] ||= Array.new
opts[:links] << [:website, link.strip]
end
op.on '--screenshot-link LINK', 'Add or remove a screenshot link' do |link|
opts[:links] ||= Array.new
opts[:links] << [:screenshot, link.strip]
end
op.on '--donation-link LINK', 'Add or remove a donation link' do |link|
opts[:links] ||= Array.new
opts[:links] << [:donation, link.strip]
end
op.on '--ls-links', 'Display the link list then exit' do
opts[:lslinks] = true
end
op.on '-A', '--about=FILE', 'Set the about content from a file' do |file|
opts[:about] = expand_path file.strip, base: basepath, relative: true
end
op.on '--remove-about', 'Remove the about content from the index' do
opts[:rmabout] = true
end
op.on '--dump-about', 'Dump the raw about content in RTF and exit' do
opts[:dump_about] = true
end
op.separator 'Misc options:'
op.on '--[no-]progress', 'Enable or disable progress information' do |bool|
opts[:progress] = bool
end
op.on '-V', '--[no-]verbose', 'Activate diagnosis messages' do |bool|
opts[:verbose] = bool
end
op.on '-C', '--[no-]commit', 'Select whether to commit the modified index' do |bool|
opts[:commit] = bool
end
op.on '--prompt-commit', 'Ask at runtime whether to commit the index' do
opts[:commit] = nil
end
op.on '-m', "--commit-template MESSAGE",
'Customize the commit message. Supported placeholder: $changelog' do |msg|
opts[:message] = msg
end
op.on '-W', '--warnings', 'Enable warnings' do
opts[:warnings] = true
end
op.on '-w', '--no-warnings', 'Turn off warnings' do
opts[:warnings] = false
end
op.on '-q', '--[no-]quiet', 'Disable almost all output' do
opts[:warnings] = false
opts[:progress] = false
opts[:verbose] = false
opts[:quiet] = true
end
op.on '--no-config', 'Bypass the configuration files' do
opts[:noconfig] = true
end
op.on_tail '-v', '--version', 'Display version information' do
puts op.ver
throw :stop, true
end
op.on_tail '-h', '--help', 'Prints this help' do
puts op
throw :stop, true
end
end.parse! args
if basepath && !args.empty?
raise OptionParser::InvalidOption, "#{args.first}"
end
opts
rescue OptionParser::ParseError => e
$stderr.puts "#{PROGRAM_NAME}: #{e.message}"
$stderr.puts "Try '#{PROGRAM_NAME} --help' for more information."
throw :stop, false
end
|