typer-plugins
Register Typer CLI applications to a main root application to make it more pluggable.
This is inspired by click-plugins so I have created a similar package to register Typer CLI based applications in a similar plugin format. It's slightly different how to use it and I'm still actively working on this project to improve the process of registering, detecting duplicate plugins. Natively running a plugin with broken code will not break the full application, only when someone attempts to execute that specific command.
But now you can manage your Typer CLI applications with plugin based architecture, managing separate sub-command groups in separate Git repositories.
How to use
pip install typer-plugins- Import the package in your main application that you want to register all your plugins into
import typer
from typer_plugins import register_plugins # Import the register_plugins function
app = typer.Typer(invoke_without_command=True)
register_plugins(app=app, entrypoint="exampleapp.plugins") # Run the function after creating your main `app`. This entrypoint should be used by all your applications.
if __name__ == "__main__":
app()
- Create your plugin(s) and ensure you either create an entrypoint, here is an example using pyproject.toml with Poetry:
[tool.poetry.plugins."exampleapp.plugins"]
"plugin-a" = "plugin_a.app:app"
This format assumes your plugin is called plugin_a and there is a python file called app.py with the Typer app created assigned to a variable named app. You can find a working example in the examples directory
- As long as your entrypoint matches up with the poetry plugin configured in the pyproject.toml file, you can now proceed to
pip install <your-plugin>whether it be locally or via a package distributer. It will then register from your main application where you use theregister_pluginsfunction.
$ python my-app plugin-a --help
Usage: my-app plugin-a [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
root-command-a
root-command-b
some-commands
some-other-commands
Development / Contributing
TO-DO
Release files for typer-plugins 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| typer_plugins-0.1.2.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| typer_plugins-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:14.9 kB
Release files / typer_plugins-0.1.2.tar.gz
| Download URL | typer_plugins-0.1.2.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6979afd6684c1cb9cfc6f926d9101f7a04360e4f0e63f9bd9be63fe4c94b6e95
|
|
BLAKE2b-256 checksum How to use checksums |
1458b8c8d17ada70607c0509186b27ad85eabbe64d6f9bcb958a04c854251b27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.15 Linux/6.5.0-1025-azure
|
Release files / typer_plugins-0.1.2-py3-none-any.whl
| Download URL | typer_plugins-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c747504746089cc2da7316e716531c32037c6cbe62c3ba26107b9120121470b2
|
|
BLAKE2b-256 checksum How to use checksums |
62952f3edfc44d061c4dc97f0a5e4f563c451f9fa8fe44bcf7931caf1397d76c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.10.15 Linux/6.5.0-1025-azure
|