Running commands/groups#
API reference#
- feud.core.run(obj, args=None, /, **kwargs)#
Run a
Group,click.Command, orclick.Group.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:
obj (type[Group] | click.Command | Callable) – Group, command or function to run.
args (list[str] | None) – Command-line arguments provided to
click.Command.**kwargs (Any) – Additional keyword arguments provided to
click.Command.
- 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