main 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +41 -0
  2. data/a.rb +7 -0
  3. data/lib/main.rb +1 -1
  4. data/lib/main/base.rb +9 -0
  5. 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
@@ -3,6 +3,13 @@ require 'main'
3
3
  Main {
4
4
  option 'bar'
5
5
 
6
+ examples 'a', 'b'
7
+
8
+ api <<-txt
9
+ foobar
10
+ barfoo
11
+ txt
12
+
6
13
  mode 'foo' do
7
14
  option('bar'){ required }
8
15
 
@@ -2,7 +2,7 @@ module Main
2
2
  #
3
3
  # top level constants
4
4
  #
5
- Main::VERSION = '2.3.0' unless
5
+ Main::VERSION = '2.5.0' unless
6
6
  defined? Main::VERSION
7
7
  def self.version() Main::VERSION end
8
8
 
@@ -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
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: main
5
5
  version: !ruby/object:Gem::Version
6
- version: 2.4.0
6
+ version: 2.5.0
7
7
  date: 2007-11-02 00:00:00 -06:00
8
8
  summary: main
9
9
  require_paths: