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 LocalApp method 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 a LocalProcessFuture for the launched run. An additional keyword argument is turned into a CLIFlag if its value is None, into multiple CLIOption if its value is a list, and into a single CLIOption otherwise. Only keyword arguments whose key is listed in allowed_options are accepted.

If options are allowed, the decorated method does not need to declare **kwargs itself: 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:

  1. It is not already set by the command method.

  2. It does not counteract or is not mutually exclusive with an option set by the command method.

  3. 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.