# File lib/kwalify/util/option-parser.rb, line 115
  def parse(argv, auto_convert=false)
    options = {}
    properties = {}
    while argv[0] && argv[0][0] == ?-
      optstr = argv.shift
      optstr = optstr[1, optstr.length-1]
      #
      if optstr[0] == ?-    ## property
        unless optstr =~ /\A\-([-\w]+)(?:=(.*))?/
          raise CommandOptionError.new(optstr, :invalid_property)
        end
        prop_name = $1;  prop_value = $2
        if auto_convert
          key   = prop_name.gsub(/-/, '_').intern
          value = prop_value.nil? ? true : CommandOptionParser.to_value(prop_value)
          properties[key] = value
        else
          properties[prop_name] = prop_value
        end
        #
      else                  ## options
        while optstr && !optstr.empty?
          optchar = optstr[0]
          optstr[0,1] = ""
          #puts "*** debug: optchar=#{optchar.chr}, optstr=#{optstr.inspect}"
          if @arg_none.include?(optchar)
            options[optchar] = true
          elsif @arg_required.include?(optchar)
            arg = optstr.empty? ? argv.shift : optstr
            raise CommandOptionError.new(optchar.chr, :no_argument) unless arg
            options[optchar] = arg
            optstr = nil
          elsif @arg_optional.include?(optchar)
            arg = optstr.empty? ? true : optstr
            options[optchar] = arg
            optstr = nil
          else
            raise CommandOptionError.new(optchar.chr, :unknown_option)
          end
        end
      end
      #
    end  # end of while

    return options, properties
  end