def remove_global_options(options, args)
      options.each do |option|
        switches = option[:switches]
        next if switches.empty?

        option_takes_argument = switches.any? { |s| s =~ /[ =]/ }
        switches = expand_optionally_negative_switches(switches)

        option_argument_needs_removal = false
        args.delete_if do |token|
          break if token == '--'

          # Use just the portion of the token before the = when
          # comparing switches.
          index_of_equals = token.index('=') if option_takes_argument
          token = token[0, index_of_equals] if index_of_equals
          token_contains_option_argument = !index_of_equals.nil?

          if switches.any? { |s| s[0, token.length] == token }
            option_argument_needs_removal =
              option_takes_argument && !token_contains_option_argument
            true
          elsif option_argument_needs_removal && token !~ /^-/
            option_argument_needs_removal = false
            true
          else
            option_argument_needs_removal = false
            false
          end
        end
      end
    end
#
Removes global _options_ from _args_. This prevents an invalid
option error from occurring when options are parsed
again for the command.