File: cmd.rb

package info (click to toggle)
liboptparse-ruby 0.8.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 428 kB
  • ctags: 644
  • sloc: ruby: 1,819; makefile: 47
file content (19 lines) | stat: -rwxr-xr-x 461 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/ruby

# This is sample script for 2-stage parse.


require 'optparse'

$0 = File.basename($0, '.rb')
cmd = nil
ARGV.options {|q|
  q.banner = "Usage: #{$0} [common-options] command [command-options-and-argument]\n"
  q.on('--[no-]debug', 'debugging') {|$DEBUG|}
  q.on('--[no-]verbose', 'run verbosely') {|$VERBOSE|}
  q.order! do |cmd|
    require "#{$0}-#{cmd}.rb"
  end
} or (STDERR.puts ARGV.options; exit 1)
p ARGV, cmd if $VERBOSE
$cmd[*ARGV]