class Rexical::Cmd

def initialize

def initialize
  @status  =  2
  @cmd  =  File.basename($0, ".rb")
  tmp  =  OPTIONS.lines.collect do |line|
      next if /\A\s*\z/ === line
      # disp, sopt, lopt, takearg, doc
      _, sopt, lopt, takearg, _  =  line.strip.split(/\s+/, 5)
      a  =  []
      a.push lopt    unless lopt == '-'
      a.push sopt    unless sopt == '-'
      a.push takearg == '-' ?
             GetoptLong::NO_ARGUMENT : GetoptLong::REQUIRED_ARGUMENT
      a
  end
  getopt  =  GetoptLong.new(*tmp.compact)
  getopt.quiet  =  true
  @opt  =  {}
  begin
    getopt.each do |name, arg|
      raise GetoptLong::InvalidOption,
          "#{@cmd}: #{name} given twice" if @opt.key? name
      @opt[name]  =  arg.empty? ? true : arg
    end
  rescue GetoptLong::AmbiguousOption, GetoptLong::InvalidOption,
         GetoptLong::MissingArgument, GetoptLong::NeedlessArgument
    usage $!.message
  end
  usage    if @opt['--help']
  if @opt['--version']
    puts "#{@cmd} version #{Rexical::VERSION}"
    exit 0
  end
  if @opt['--copyright']
    puts "#{@cmd} version #{Rexical::VERSION}"
    puts "#{Rexical::Copyright} <#{Rexical::Mailto}>"
    exit 0
  end
end