Invokes a command in an isolated environment. The arguments are forwarded directly to the command line script, the `extra` keyword arguments are passed to the :meth:`~clickpkg.Command.main` function of the command. This returns a :class:`Result` object. :pa
(
self,
cli: Command,
args: str | cabc.Sequence[str] | None = None,
input: str | bytes | t.IO[t.Any] | None = None,
env: cabc.Mapping[str, str | None] | None = None,
catch_exceptions: bool | None = None,
color: bool = False,
**extra: t.Any,
)
| 594 | pdb.Pdb.__init__ = old_pdb_init class="cm"># type: ignore[method-assign] |
| 595 | |
| 596 | def invoke( |
| 597 | self, |
| 598 | cli: Command, |
| 599 | args: str | cabc.Sequence[str] | None = None, |
| 600 | input: str | bytes | t.IO[t.Any] | None = None, |
| 601 | env: cabc.Mapping[str, str | None] | None = None, |
| 602 | catch_exceptions: bool | None = None, |
| 603 | color: bool = False, |
| 604 | **extra: t.Any, |
| 605 | ) -> Result: |
| 606 | class="st">"""Invokes a command in an isolated environment. The arguments are |
| 607 | forwarded directly to the command line script, the `extra` keyword |
| 608 | arguments are passed to the :meth:`~clickpkg.Command.main` function of |
| 609 | the command. |
| 610 | |
| 611 | This returns a :class:`Result` object. |
| 612 | |
| 613 | :param cli: the command to invoke |
| 614 | :param args: the arguments to invoke. It may be given as an iterable |
| 615 | or a string. When given as string it will be interpreted |
| 616 | as a Unix shell command. More details at |
| 617 | :func:`shlex.split`. |
| 618 | :param input: the input data for `sys.stdin`. |
| 619 | :param env: the environment overrides. |
| 620 | :param catch_exceptions: Whether to catch any other exceptions than |
| 621 | ``SystemExit``. If :data:`None`, the value |
| 622 | from :class:`CliRunner` is used. |
| 623 | :param extra: the keyword arguments to pass to :meth:`main`. |
| 624 | :param color: whether the output should contain color codes. The |
| 625 | application can still override this explicitly. |
| 626 | |
| 627 | .. versionadded:: 8.2 |
| 628 | The result object has the ``output_bytes`` attribute with |
| 629 | the mix of ``stdout_bytes`` and ``stderr_bytes``, as the user would |
| 630 | see it in its terminal. |
| 631 | |
| 632 | .. versionchanged:: 8.2 |
| 633 | The result object always returns the ``stderr_bytes`` stream. |
| 634 | |
| 635 | .. versionchanged:: 8.0 |
| 636 | The result object has the ``return_value`` attribute with |
| 637 | the value returned from the invoked command. |
| 638 | |
| 639 | .. versionchanged:: 4.0 |
| 640 | Added the ``color`` parameter. |
| 641 | |
| 642 | .. versionchanged:: 3.0 |
| 643 | Added the ``catch_exceptions`` parameter. |
| 644 | |
| 645 | .. versionchanged:: 3.0 |
| 646 | The result object has the ``exc_info`` attribute with the |
| 647 | traceback if available. |
| 648 | class="st">""" |
| 649 | exc_info = None |
| 650 | if catch_exceptions is None: |
| 651 | catch_exceptions = self.catch_exceptions |
| 652 | |
| 653 | class="cm"># Set up fd capture before isolation replaces sys.stdout and sys.stderr. |
no test coverage detected