-
-
Notifications
You must be signed in to change notification settings - Fork 7
Authoring plugins
- Take a look at fichub-cli-metadata to see how to implement a plugin.
.
├── fichub_cli_[plugin_name]
│ ├── cli.py
│ └──__init__.py
├── LICENSE.txt
├── pyproject.toml
├── README.md
├── requirements_dev.txt
├── requirements_prod.txt
├── setup.cfg
└── setup.py
-
As seen in the above directory structure, an app directory that starts with
fichub_cli_
needs to be created i.e.fichub_cli_[plugin_name]
in the root directory as shown in the reference plugin and the package name insetup.py
also needs to be infichub_cli_[plugin_name]
format as the plugins are discovered using naming conventions. -
As shown in the
fichub_cli_[plugin_name]/cli.py
file, create a typerapp
and make a@app.callback()
for each command. Read the Typer Docs for more information on how to make a CLI. -
Add
from .cli import app
to thefichub_cli_[plugin_name]/__init__.py
file. -
Add
fichub-cli
version to the "install_requires" parameter in thesetup.py
-
To reuse code from
fichub-cli
in your plugin, import using:from fichub_cli.utils.processing import check_url
-
You can also import any class from the core cli and inherit & override the functions according to your needs.
-
fichub-cli-metadata implemented this in its fichub.py to import
Fichub
class from the core cli and override theget_fic_metadata()
function with code necessary for the plugin.
-
fichub-cli-metadata implemented this in its fichub.py to import
-
Ask the project maintainer for help if you run into any problems by creating a discussion or contacting them directly if necessary.