command#
- biotite.application_v2.command(method: Callable[[...], CommandSetup[T]] | None = None, *, subcommand: str | None = None, allowed_options: list[str] | None = None) Callable[[...], Any][source]#
Turn a
LocalAppmethod into a runnable command.The decorated method must return a
CommandSetup. The resulting method accepts additional keyword arguments beyond its own parameters, which are added as command line options, and returns aLocalProcessFuturefor the launched run. An additional keyword argument is turned into aCLIFlagif its value isNone, into multipleCLIOptionif its value is a list, and into a singleCLIOptionotherwise. Only keyword arguments whose key is listed in allowed_options are accepted.If options are allowed, the decorated method does not need to declare
**kwargsitself: The decorator adds them to the signature and to the Parameters section of the docstring, so that they appear in the documentation.- Parameters:
- methodcallable, optional
The decorated method. Supplied automatically when the decorator is applied without parentheses.
- subcommandstr, optional
A subcommand appended to the executable, before the options and arguments.
- allowed_optionslist of str, optional
The keys of the command line options that may be passed as extra keyword arguments. By default, no extra options are allowed.
- Returns:
- decoratedcallable
The decorated method or, if method is not given, a decorator.
- Raises:
- ValueError
If an extra keyword argument not listed in allowed_options is used.
Notes
An option should only be added to allowed_options, if all of the following conditions are met:
It is not already set by the command method.
It does not counteract or is not mutually exclusive with an option set by the command method.
It does not break the logic of the command method, i.e. it must not change the expected input format or the formatting of the output.