import functools

from curious.commands.command import Command


def command(*args, **kwargs):
    """
    A decorator to mark a function as a command.
    This will put a `factory` attribute on the function, which can later be called to create the Command instance.

    All arguments are passed to the Command class.
    """

    def __inner(func):
        factory = functools.partial(Command, func, *args, **kwargs)
        func.factory = factory
        return func

    return __inner


def event(func):
    """
    Marks a function as an event.

    :param func: Either the function, or the name to give to the event.
    """
    if isinstance(func, str):
        def __innr(f):
            f.event = func
            return f

        return __innr
    else:
        func.event = func.__name__[3:]
        return func

import functools

from curious.commands.command import Command


def command(*args, klass: type=Command, **kwargs):
    """
    A decorator to mark a function as a command.
    This will put a `factory` attribute on the function, which can later be called to create the Command instance.

    All arguments are passed to the Command class.

    :param klass: The command class type to wrap the object in.
    """

    def __inner(func):
        factory = functools.partial(klass, func, *args, **kwargs)
        func.factory = factory
        return func

    return __inner


def event(func):
    """
    Marks a function as an event.

    :param func: Either the function, or the name to give to the event.
    """
    if isinstance(func, str):
        def __innr(f):
            f.event = func
            return f

        return __innr
    else:
        func.event = func.__name__[3:]
        return func

Allow changing what object is returned from Command instances.
Allow changing what object is returned from Command instances.

  import functools
  
  from curious.commands.command import Command
  
  
- def command(*args, **kwargs):
+ def command(*args, klass: type=Command, **kwargs):
      """
      A decorator to mark a function as a command.
      This will put a `factory` attribute on the function, which can later be called to create the Command instance.
  
      All arguments are passed to the Command class.
+ 
+     :param klass: The command class type to wrap the object in.
      """
  
      def __inner(func):
-         factory = functools.partial(Command, func, *args, **kwargs)
+         factory = functools.partial(klass, func, *args, **kwargs)
          func.factory = factory
          return func
  
      return __inner
  
  
  def event(func):
      """
      Marks a function as an event.
  
      :param func: Either the function, or the name to give to the event.
      """
      if isinstance(func, str):
          def __innr(f):
              f.event = func
              return f
  
          return __innr
      else:
          func.event = func.__name__[3:]
          return func
  
Allow changing what object is returned from Command instances.
## Code Before:
import functools

from curious.commands.command import Command


def command(*args, **kwargs):
    """
    A decorator to mark a function as a command.
    This will put a `factory` attribute on the function, which can later be called to create the Command instance.

    All arguments are passed to the Command class.
    """

    def __inner(func):
        factory = functools.partial(Command, func, *args, **kwargs)
        func.factory = factory
        return func

    return __inner


def event(func):
    """
    Marks a function as an event.

    :param func: Either the function, or the name to give to the event.
    """
    if isinstance(func, str):
        def __innr(f):
            f.event = func
            return f

        return __innr
    else:
        func.event = func.__name__[3:]
        return func

## Instruction:
Allow changing what object is returned from Command instances.
## Code After:
import functools

from curious.commands.command import Command


def command(*args, klass: type=Command, **kwargs):
    """
    A decorator to mark a function as a command.
    This will put a `factory` attribute on the function, which can later be called to create the Command instance.

    All arguments are passed to the Command class.

    :param klass: The command class type to wrap the object in.
    """

    def __inner(func):
        factory = functools.partial(klass, func, *args, **kwargs)
        func.factory = factory
        return func

    return __inner


def event(func):
    """
    Marks a function as an event.

    :param func: Either the function, or the name to give to the event.
    """
    if isinstance(func, str):
        def __innr(f):
            f.event = func
            return f

        return __innr
    else:
        func.event = func.__name__[3:]
        return func
