def command!(commands)
      command = nil
      command_index = 0
      each_with_index do |arg, i|
        break if arg == '--'

        command = commands[arg.to_sym]
        unless command.nil?
          command_index = i
          delete_at i
          break
        end
      end
      delete '--'

      command ||= commands[:__default]

      return command, command_index
    end
def command!(commands)
      command = nil
      command_index = 0
      each_with_index do |arg, i|
        break if arg == '--'

        command = commands[arg.to_sym]
        unless command.nil?
          command_index = i
          delete_at i
          break
        end
      end
      delete '--'

      command ||= commands[:__default]

      return command, command_index
    end
Gets the command to use from the list of arguments passed to the
 application. The first argument matching a command name or alias will
 cause the corresponding command to be selected.

 The command and all arguments equal to '--' will be removed from the
 array.

 @param [Hash<Symbol, Command>] commands A list of available commands
 @return [Command] The command found in the argument list
 @return [Fixnum] The position of the command in the argument list