Skip to content

Authoring plugins

Arbaaz edited this page Feb 20, 2022 · 4 revisions

Reference

App directory structure

.
├── fichub_cli_[plugin_name]
│ ├── cli.py
│ └──__init__.py
├── LICENSE.txt
├── pyproject.toml
├── README.md
├── requirements_dev.txt
├── requirements_prod.txt
├── setup.cfg
└── setup.py

Notes

  • 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 in setup.py also needs to be in fichub_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 typer app 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 the fichub_cli_[plugin_name]/__init__.py file.

  • Add fichub-cli version to the "install_requires" parameter in the setup.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 the get_fic_metadata() function with code necessary for the plugin.
  • Ask the project maintainer for help if you run into any problems by creating a discussion or contacting them directly if necessary.

Clone this wiki locally