Running commands/groups#


API reference#

feud.core.run(obj, args=None, /, **kwargs)#

Run a Group, click.Command, or click.Group.

If called on a function, it will be decorated with command() using the default configuration to convert it into a click.Command which will then be executed.

Parameters:
Return type:

Output of the called click.Command.

Examples

Running an undecorated function.

>>> import feud
>>> def func(*, opt: int) -> int:
...     return opt
>>> feud.run(func, ["--opt", "3"], standalone_mode=False)
3

Running a click.Command.

>>> import feud
>>> @feud.command
... def func(*, opt: int) -> int:
...     return opt
>>> feud.run(func, ["--opt", "3"], standalone_mode=False)
3

Running a Group.

>>> import feud
>>> class CLI(feud.Group):
...     def func(*, opt: int) -> int:
...         return opt
>>> feud.run(CLI, ["func", "--opt", "3"], standalone_mode=False)
3

Running a click.Group.

>>> import feud
>>> from feud import click
>>> class CLI(feud.Group):
...     def func(*, opt: int) -> int:
...         return opt
>>> group: click.Group = feud.compile(CLI)
>>> feud.run(group, ["func", "--opt", "3"], standalone_mode=False)
3