argclz.dispatch.annotations.dispatch#
- argclz.dispatch.annotations.dispatch(command, *alias, group=None, order=5, usage=None, hidden=False)[source]#
A decorator that mark a function as a dispatch target function.
All functions decorated in same dispatch group should have save function signature (at least for non-default parameters). For example:
Example
>>> class D(Dispatch): ... @dispatch('A') ... def function_a(self, a, b, c=None): ... pass ... @dispatch('B') ... def function_b(self, a, b, d=None): ... pass ... def run_function(self): ... self.invoke_command(self, 'A', a, b)
- Parameters:
command (str) – primary command name
alias (str) – secondary command names
group (str | None) – command group
order (float) – order of this command shown in the
build_command_usages()usage (str | None) – usage line of this command shown in the
build_command_usages()hidden – hide this command from
list_commands()
- Return type:
Callable[[F], F]