Running commands/groups#
API reference#
- feud.core.run(obj, args=None, /, **kwargs)#
Run a
Group,click.Command, orclick.Group.Multiple functions/commands can also be provided as a
dictor iterable object.If called on a function, it will be decorated with
command()using the default configuration to convert it into aclick.Commandwhich 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
Running a
dictof functions/commands.>>> import feud >>> def func1(*, opt: int) -> int: ... return opt >>> def func2(*, opt: float) -> float: ... return opt >>> feud.run( ... {"func1": func1, "func2": func2}, ... ["func2", "--opt", "0.12"], ... standalone_mode=False, ... ) 0.12
Running a collection of functions/commands.
>>> import feud >>> def func1(*, opt: int) -> int: ... return opt >>> def func2(*, opt: float) -> float: ... return opt >>> feud.run( ... (func1, func2), ... ["func2", "--opt", "0.12"], ... standalone_mode=False, ... ) 0.12