Skip to content

Commit e2bc84c

Browse files
committed
- Improved options processing and usage output to be more clear.
Including supporting --exclude as -x which I always accidentally do. [git-p4: depot-paths = "//src/minitest/dev/": change = 14606]
1 parent 15265da commit e2bc84c

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lib/minitest.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,41 +147,56 @@ def self.process_args args = [] # :nodoc:
147147
orig_args = args.dup
148148

149149
OptionParser.new do |opts|
150-
opts.banner = "minitest options:"
150+
opts.program_name = "minitest"
151151
opts.version = Minitest::VERSION
152152

153+
opts.banner = [
154+
"Usage: rake test [A=options] (see Minitest::TestTask for more options)",
155+
"minitest [paths] [options] (with minitest-sprint gem)",
156+
"ruby path/to/test.rb [options]\n\n",
157+
].join "\n or: "
158+
153159
opts.on "-h", "--help", "Display this help." do
154160
puts opts
155161
exit
156162
end
157163

158-
opts.on "--no-plugins", "Bypass minitest plugin auto-loading (or set $MT_NO_PLUGINS)."
164+
opts.on "--no-plugins", "Bypass minitest plugin auto-loading (or env: MT_NO_PLUGINS=1)."
159165

160-
desc = "Sets random seed. Also via env. Eg: SEED=n rake"
166+
desc = "Sets random seed. Also via env, eg: SEED=42"
161167
opts.on "-s", "--seed SEED", Integer, desc do |m|
162-
options[:seed] = m.to_i
168+
options[:seed] = m
163169
end
164170

165-
opts.on "-v", "--verbose", "Verbose. Show progress processing files." do
171+
opts.on "-v", "--verbose", "Verbose. Print each name as they run." do
166172
options[:verbose] = true
167173
end
168174

169-
opts.on "-q", "--quiet", "Quiet. Show no progress processing files." do
175+
opts.on "-q", "--quiet", "Quiet. Show no dots while processing files." do
170176
options[:quiet] = true
171177
end
172178

173179
opts.on "--show-skips", "Show skipped at the end of run." do
174180
options[:show_skips] = true
175181
end
176182

177-
opts.on "-n", "--name PATTERN", "Filter run on /regexp/ or string." do |a|
183+
opts.on "-n", "--name PATTERN", "Include /regexp/ or string for run." do |a|
178184
options[:filter] = a
179185
end
180186

181187
opts.on "-e", "--exclude PATTERN", "Exclude /regexp/ or string from run." do |a|
182188
options[:exclude] = a
183189
end
184190

191+
# omg wtf
192+
def opts.short_alias(from, to) = top.short[to] = top.short[from]
193+
def opts.long_alias(from, to) = top.long[to] = top.long[from]
194+
195+
# these will work but won't show up in --help output:
196+
opts.long_alias "name", "include"
197+
opts.short_alias "n", "i"
198+
opts.short_alias "e", "x"
199+
185200
opts.on "-S", "--skip CODES", String, "Skip reporting of certain types of results (eg E)." do |s|
186201
options[:skip] = s.chars.to_a
187202
end

0 commit comments

Comments
 (0)