code: def command(
      name: t.Union[t.Optional[str], _AnyCallable] = None,
      cls: t.Optional[t.Type[CmdType]] = None,
      **attrs: t.Any,
  ) -> t.Union[
      Command, t.Callable[[_AnyCallable], t.Union[Command, CmdType]]
  ]:
      r"""Creates a new :class:`Command` and uses the decorated function as
      callback.  This will also automatically attach all decorated
      :func:`option`\s and :func:`argument`\s as parameters to the command.
  
      The name of the command defaults to the name of the function with
      underscores replaced by dashes.  If you want to change that, you can
      pass the intended name as the first argument.
  
      All keyword arguments are forwarded to the underlying command class.
      For the ``params`` argument, any decorated params are appended to
      the end of the list.
  
      Once decorated the function turns into a :class:`Command` instance
      that can be invoked as a command line utility or be attached to a
      command :class:`Group`.
  
      :param name: the name of the command.  This defaults to the function
                   name with underscores replaced by dashes.
      :param cls: the command class to instantiate.  This defaults to
                  :class:`Command`.
  
      .. versionchanged:: 8.1
          This decorator can be applied without parentheses.
  
      .. versionchanged:: 8.1
          The ``params`` argument can be used. Decorated params are
          appended to the end of the list.
      """
  
      func: t.Optional[t.Callable[[_AnyCallable], t.Any]] = None
  
      if callable(name):
          func = name
          name = None
          assert (
              cls is None
          ), "Use 'command(cls=cls)(callable)' to specify a class."
          assert (
              not attrs
          ), "Use 'command(**kwargs)(callable)' to provide arguments."
  
      if cls is None:
          cls = t.cast(t.Type[CmdType], Command)
  
      def decorator(f: _AnyCallable) -> CmdType:
          if isinstance(f, Command):
              raise TypeError(
                  "Attempted to convert a callback into a command twice."
              )
  
          attr_params = attrs.pop("params", None)
          params = attr_params if attr_params is not None else []
  
          try:
              decorator_params = f.__click_params__  # type: ignore
          except AttributeError:
              pass
          else:
              del f.__click_params__  # type: ignore
              params.extend(reversed(decorator_params))
  
          if attrs.get("help") is None:
              attrs["help"] = f.__doc__
  
          if t.TYPE_CHECKING:
              assert cls is not None
              assert not callable(name)
  
          cmd = cls(
              name=name or f.__name__.lower().replace("_", "-"),
              callback=f,
              params=params,
              **attrs,
          )
          cmd.__doc__ = f.__doc__
          return cmd
  
      if func is not None:
          return decorator(func)
  
      return decorator
  
imports: import inspect
  import types
  import typing
  from functools import update_wrapper
  from gettext import gettext
  from .core import Argument
  from .core import Command
  from .core import Context
  from .core import Group
  from .core import Option
  from .core import Parameter
  from .globals import get_current_context
  from .utils import echo
label_desc: Use image node_id 9 for calling a global function with example usage: command(name, cls) and returns: decorator, cmd, decorator