main 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +41 -0
- data/a.rb +7 -0
- data/lib/main.rb +1 -1
- data/lib/main/base.rb +9 -0
- metadata +1 -1
data/README
CHANGED
@@ -370,6 +370,47 @@ DOCS
|
|
370
370
|
API section below
|
371
371
|
|
372
372
|
HISTORY
|
373
|
+
2.5.0
|
374
|
+
- added 'examples', 'samples', and 'api' kewords to main dsl. each
|
375
|
+
keyword takes a list of strings which will be included in the help
|
376
|
+
message
|
377
|
+
|
378
|
+
Main {
|
379
|
+
examples "foobar example", "barfoo example"
|
380
|
+
|
381
|
+
samples <<-txt
|
382
|
+
do this
|
383
|
+
|
384
|
+
don't do that
|
385
|
+
txt
|
386
|
+
|
387
|
+
api %(
|
388
|
+
foobar string, hash
|
389
|
+
|
390
|
+
barfoo hash, string
|
391
|
+
)
|
392
|
+
}
|
393
|
+
|
394
|
+
results in a usage message with sections like
|
395
|
+
|
396
|
+
...
|
397
|
+
|
398
|
+
EXAMPLES
|
399
|
+
foobar example
|
400
|
+
barfoo example
|
401
|
+
|
402
|
+
SAMPLES
|
403
|
+
do this
|
404
|
+
|
405
|
+
don't do that
|
406
|
+
|
407
|
+
API
|
408
|
+
foobar string, hash
|
409
|
+
|
410
|
+
barfoo hash, string
|
411
|
+
|
412
|
+
...
|
413
|
+
|
373
414
|
2.4.0
|
374
415
|
- fixed bug where 'abort("message")' would print "message" twice on exit
|
375
416
|
if running under a nested mode.
|
data/a.rb
CHANGED
data/lib/main.rb
CHANGED
data/lib/main/base.rb
CHANGED
@@ -175,6 +175,15 @@ module Main
|
|
175
175
|
end
|
176
176
|
modes.add klass
|
177
177
|
end
|
178
|
+
|
179
|
+
%w[ examples samples api ].each do |chunkname|
|
180
|
+
module_eval <<-code
|
181
|
+
def #{ chunkname } *a, &b
|
182
|
+
txt = b ? b.call : a.join("\\n")
|
183
|
+
usage['#{ chunkname }'] = txt
|
184
|
+
end
|
185
|
+
code
|
186
|
+
end
|
178
187
|
end
|
179
188
|
extend DSL
|
180
189
|
|