:orphan:

:mod:`cloup._context`
=====================

.. py:module:: cloup._context





                              
Classes
-------

.. autosummary::

   ~cloup._context.Context

Functions
---------

.. autosummary::

   ~cloup._context.get_current_context
   ~cloup._context.pass_context

Attributes
----------

.. autoapisummary::

   cloup._context.P
   cloup._context.R

                                           
Contents
--------
.. py:data:: P
   

   

.. py:data:: R
   

   

.. py:function:: get_current_context() -> Context
              get_current_context(silent: bool = False) -> Optional[Context]

   Equivalent to :func:`click.get_current_context` but casts the returned
   :class:`click.Context` object to :class:`cloup.Context` (which is safe when using
   cloup commands classes and decorators).


.. py:function:: pass_context(f)

   Marks a callback as wanting to receive the current context object as first
   argument. Equivalent to :func:`click.pass_context` but assumes the current context
   is of type :class:`cloup.Context`.


.. py:class:: Context(*ctx_args, align_option_groups = None, align_sections = None, show_subcommand_aliases = None, show_constraints = None, check_constraints_consistency = None, formatter_settings = {}, **ctx_kwargs)

   Bases: :py:obj:`click.Context`

   A custom context for Cloup.

   Look up :class:`click.Context` for the list of all arguments.

   .. versionadded:: 0.9.0
       added the ``check_constraints_consistency`` parameter.

   .. versionadded:: 0.8.0

   :param ctx_args:
       arguments forwarded to :class:`click.Context`.
   :param align_option_groups:
       if True, align the definition lists of all option groups of a command.
       You can override this by setting the corresponding argument of ``Command``
       (but you probably shouldn't: be consistent).
   :param align_sections:
       if True, align the definition lists of all subcommands of a group.
       You can override this by setting the corresponding argument of ``Group``
       (but you probably shouldn't: be consistent).
   :param show_subcommand_aliases:
       whether to show the aliases of subcommands in the help of a ``cloup.Group``.
   :param show_constraints:
       whether to include a "Constraint" section in the command help (if at
       least one constraint is defined).
   :param check_constraints_consistency:
       enable additional checks for constraints which detects mistakes of the
       developer (see :meth:`cloup.Constraint.check_consistency`).
   :param formatter_settings:
       keyword arguments forwarded to :class:`HelpFormatter` in ``make_formatter``.
       This args are merged with those of the (eventual) parent context and then
       merged again (being overridden) by those of the command.
       **Tip**: use the static method :meth:`HelpFormatter.settings` to create this
       dictionary, so that you can be guided by your IDE.
   :param ctx_kwargs:
       keyword arguments forwarded to :class:`click.Context`.

   .. py:attribute:: formatter_class
      :annotation: :Type[cloup.formatting.HelpFormatter]

      

   .. py:method:: get_formatter_settings()


   .. py:method:: make_formatter()

      Creates the :class:`~click.HelpFormatter` for the help and
      usage output.

      To quickly customize the formatter class used without overriding
      this method, set the :attr:`formatter_class` attribute.

      .. versionchanged:: 8.0
          Added the :attr:`formatter_class` attribute.


   .. py:method:: settings(*, auto_envvar_prefix = MISSING, default_map = MISSING, terminal_width = MISSING, max_content_width = MISSING, resilient_parsing = MISSING, allow_extra_args = MISSING, allow_interspersed_args = MISSING, ignore_unknown_options = MISSING, help_option_names = MISSING, token_normalize_func = MISSING, color = MISSING, show_default = MISSING, align_option_groups = MISSING, align_sections = MISSING, show_subcommand_aliases = MISSING, show_constraints = MISSING, check_constraints_consistency = MISSING, formatter_settings = MISSING)
      :staticmethod:

      Utility method for creating a ``context_settings`` dictionary.

      :param auto_envvar_prefix:
          the prefix to use for automatic environment variables. If this is
          `None` then reading from environment variables is disabled. This
          does not affect manually set environment variables which are always
          read.
      :param default_map:
          a dictionary (like object) with default values for parameters.
      :param terminal_width:
          the width of the terminal. The default is inherited from parent
          context. If no context defines the terminal width then auto-detection
          will be applied.
      :param max_content_width:
          the maximum width for content rendered by Click (this currently
          only affects help pages). This defaults to 80 characters if not
          overridden. In other words: even if the terminal is larger than
          that, Click will not format things wider than 80 characters by
          default.  In addition to that, formatters might add some safety
          mapping on the right.
      :param resilient_parsing:
          if this flag is enabled then Click will parse without any
          interactivity or callback invocation. Default values will also be
          ignored. This is useful for implementing things such as completion
          support.
      :param allow_extra_args:
          if this is set to `True` then extra arguments at the end will not
          raise an error and will be kept on the context. The default is to
          inherit from the command.
      :param allow_interspersed_args:
          if this is set to `False` then options and arguments cannot be
          mixed.  The default is to inherit from the command.
      :param ignore_unknown_options:
          instructs click to ignore options it does not know and keeps them
          for later processing.
      :param help_option_names:
          optionally a list of strings that define how the default help
          parameter is named. The default is ``['--help']``.
      :param token_normalize_func:
          an optional function that is used to normalize tokens (options,
          choices, etc.). This for instance can be used to implement
          case-insensitive behavior.
      :param color:
          controls if the terminal supports ANSI colors or not. The default
          is auto-detection. This is only needed if ANSI codes are used in
          texts that Click prints which is by default not the case. This for
          instance would affect help output.
      :param show_default: Show defaults for all options. If not set,
          defaults to the value from a parent context. Overrides an
          option's ``show_default`` argument.
      :param align_option_groups:
          if True, align the definition lists of all option groups of a command.
          You can override this by setting the corresponding argument of ``Command``
          (but you probably shouldn't: be consistent).
      :param align_sections:
          if True, align the definition lists of all subcommands of a group.
          You can override this by setting the corresponding argument of ``Group``
          (but you probably shouldn't: be consistent).
      :param show_subcommand_aliases:
          whether to show the aliases of subcommands in the help of a ``cloup.Group``.
      :param show_constraints:
          whether to include a "Constraint" section in the command help (if at
          least one constraint is defined).
      :param check_constraints_consistency:
          enable additional checks for constraints which detects mistakes of the
          developer (see :meth:`cloup.Constraint.check_consistency`).
      :param formatter_settings:
          keyword arguments forwarded to :class:`HelpFormatter` in ``make_formatter``.
          This args are merged with those of the (eventual) parent context and then
          merged again (being overridden) by those of the command.
          **Tip**: use the static method :meth:`HelpFormatter.settings` to create this
          dictionary, so that you can be guided by your IDE.




                                         