Extension#
- class graftkit.Extension[source]#
Bases:
FrozenModelWhat a repository adds to the core: a name and a factory of its commands.
The factory receives the
Repo, so commands never work out the root themselves.- Attributes:
- namestr
The extension’s name: its entry point and
[cli] extension.- commandsCallable[[Repo], tuple[Command, …]]
Returns the repository’s top-level commands for a root.
- packagestr | None
The commands package when built with
from_package, for conformance.
Methods
from_package(name, package)Return an extension whose commands are the modules of a package.
- classmethod from_package(name: str, package: str) Extension[source]#
Return an extension whose commands are the modules of a package.
Every module in the package defines
command(repo: Repo) -> Command; modules whose names start with an underscore are helpers and are skipped. Commands appear in module name order.- Parameters:
- namestr
The extension’s name, equal to its entry point name.
- packagestr
The dotted name of the commands package.
- Returns:
- Extension
The extension.