command#
- class efiboot.cli.command(fn)#
A decorator for CLI command functions.
The efiboot CLI is built from
command
objects. Command objects are implemented as regular functions annotated with the@command
decorator. The docstrings of these functions are written in docopt format, which is used to generate the argv parser.All commands take an argument dictionary as their first argument and a
Config
as a keyword argument. They return an integer exit code.When calling a command object, you may pass a list of strings instead of an argument dict. In this case, the list will be parsed as an argv list using docopt and converted into an args dictionary.
See also
See the module-level docs for information on how to register efiboot commands from third-party packages.
Example
from efiboot import EfiBoot from efiboot.cli import command from efiboot.config import Config @command def status(args: Dict[str, Any], config: Config) -> int: """Print EFI boot entries. Usage: efiboot status efiboot status --help Options: -h, --help Print this help message and exit. """ facade = EfiBoot(config) facade.print_state() return 0
Methods
Initialize the command object.
Attributes