Method: ALib::AbstractMain#usage
- Defined in:
- lib/alib-0.5.0/main.rb
#usage(port = STDERR) ⇒ Object
–}}}
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/alib-0.5.0/main.rb', line 501 def usage port = STDERR #--{{{ port << klass::usage << "\n" if(klass::usage and not klass::usage.empty?) port << klass::examples << "\n" if(klass::examples and not klass::examples.empty?) if klass::optspec port << 'OPTIONS' << "\n" klass::optspec.each do |os| a, b, c = os long, short, desc = nil [a,b,c].each do |word| next unless word word.strip! case word when %r/^--[^-]/o long = word when %r/^-[^-]/o short = word else desc = word end end spec = ((long and short) ? [long, short] : [long]) if spec port << Util::columnize(spec.join(', '), :width => 80, :indent => 2) port << "\n" end if desc port << Util::columnize(desc, :width => 80, :indent => 8) port << "\n" end end port << "\n" end port #--}}} end |