def remove_global_options(options, args)
      # TODO: refactor with flipflop, please TJ ! have time to refactor me !
      options.each do |option|
        switches = option[:switches].dup
        next if switches.empty?

        if (switch_has_arg = switches.any? { |s| s =~ /[ =]/ })
          switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] }
        end

        switches = expand_optionally_negative_switches(switches)

        past_switch, arg_removed = false, false
        args.delete_if do |arg|
          if switches.any? { |s| s[0, arg.length] == arg }
            arg_removed = !switch_has_arg
            past_switch = true
          elsif past_switch && !arg_removed && arg !~ /^-/
            arg_removed = true
          else
            arg_removed = true
            false
          end
        end
      end
    end
def remove_global_options(options, args)
      # TODO: refactor with flipflop, please TJ ! have time to refactor me !
      options.each do |option|
        switches = option[:switches].dup
        next if switches.empty?

        if (switch_has_arg = switches.any? { |s| s =~ /[ =]/ })
          switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] }
        end

        switches = expand_optionally_negative_switches(switches)

        past_switch, arg_removed = false, false
        args.delete_if do |arg|
          if switches.any? { |s| s[0, arg.length] == arg }
            arg_removed = !switch_has_arg
            past_switch = true
          elsif past_switch && !arg_removed && arg !~ /^-/
            arg_removed = true
          else
            arg_removed = true
            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.