def classify_tokens(tokens)
            if tokens.is_a?(String)
                require 'csv'
                tokens = CSV.parse(tokens, col_sep: ' ').first
            end
            tokens = [] unless tokens
            pos_vals = []
            kw_vals = {}
            rest_vals = []

            arg = nil
            pos_args = @definition.positional_args
            tokens.each_with_index do |token, i|
                case token
                when '/?', '-?', '--help'
                    @show_help = true
                when /^[-\/]([a-z0-9]+)$/i
                    $1.to_s.each_char do |sk|
                        kw_vals[arg] = nil if arg
                        arg = @definition[sk]
                        if FlagArgument === arg
                            kw_vals[arg] = true
                            arg = nil
                        elsif PoistionalArgument == arg
                            pos_args.delete(arg)
                        end
                    end
                when /^--(no-)?(.+)/i
                    kw_vals[arg] = nil if arg
                    arg = @definition[$2]
                    if FlagArgument === arg || (KeywordArgument === arg && $1)
                        kw_vals[arg] = $1 ? false : true
                        arg = nil
                    elsif PositionalArgument === arg
                        pos_args.delete(arg)
                    end
                when '--'
                    # All subsequent values are rest args
                    kw_vals[arg] = nil if arg
                    unless rest_vals.empty?
                        self.errors << "Too many positional arguments supplied before -- token"
                    end
                    rest_vals = tokens[(i + 1)..-1]
                    break
                else
                    if arg
                        kw_vals[arg] = token
                    elsif pos_arg.size > 0
                        pos_vals << token
                        arg = pos_args.shift
                    else
                        rest_vals << token
                    end
                    tokens[i] = '******' if arg && arg.sensitive?
                    arg = nil
                end
            end
            kw_vals[arg] = nil if arg
            [pos_vals, kw_vals, rest_vals]
        end
def classify_tokens(tokens)
            if tokens.is_a?(String)
                require 'csv'
                tokens = CSV.parse(tokens, col_sep: ' ').first
            end
            tokens = [] unless tokens
            pos_vals = []
            kw_vals = {}
            rest_vals = []

            arg = nil
            pos_args = @definition.positional_args
            tokens.each_with_index do |token, i|
                case token
                when '/?', '-?', '--help'
                    @show_help = true
                when /^[-\/]([a-z0-9]+)$/i
                    $1.to_s.each_char do |sk|
                        kw_vals[arg] = nil if arg
                        arg = @definition[sk]
                        if FlagArgument === arg
                            kw_vals[arg] = true
                            arg = nil
                        elsif PoistionalArgument == arg
                            pos_args.delete(arg)
                        end
                    end
                when /^--(no-)?(.+)/i
                    kw_vals[arg] = nil if arg
                    arg = @definition[$2]
                    if FlagArgument === arg || (KeywordArgument === arg && $1)
                        kw_vals[arg] = $1 ? false : true
                        arg = nil
                    elsif PositionalArgument === arg
                        pos_args.delete(arg)
                    end
                when '--'
                    # All subsequent values are rest args
                    kw_vals[arg] = nil if arg
                    unless rest_vals.empty?
                        self.errors << "Too many positional arguments supplied before -- token"
                    end
                    rest_vals = tokens[(i + 1)..-1]
                    break
                else
                    if arg
                        kw_vals[arg] = token
                    elsif pos_arg.size > 0
                        pos_vals << token
                        arg = pos_args.shift
                    else
                        rest_vals << token
                    end
                    tokens[i] = '******' if arg && arg.sensitive?
                    arg = nil
                end
            end
            kw_vals[arg] = nil if arg
            [pos_vals, kw_vals, rest_vals]
        end
Evaluate the list of values in +tokens+, and classify them as either
 keyword/value pairs, or positional arguments. Ideally this would be
 done without any reference to the defined arguments, but unfortunately
 a keyword arg cannot be distinguished from a flag arg followed by a
 positional arg without the context of what arguments are expected.