Skip to main content

Click Command Loader, permit to load Click command from a given folder.

Project description

Click Command Loader (CCL)

Click Command Loader

Click Command Loader (Referred as CCL) is an additional package for Click to load Click commands from a folder.

As such, by having the following folder structure:

├─ commands/
│  ├─
│  ├─
│  ├─

The commands create, delete and list will be registered in your Click app!


I'm a package that is available on PyPi!

With Pip

pip install clickloader

With Poetry

poetry add clickloader


Let's consider you have the following commands structure:

├─ commands/
│  ├─
│  ├─
│  ├─

Inside your, you should have your base logic for your CLI app. Originally, this is where all your commands would be registered, but CCL will help you leverage the work here.

Here's is what the content of the would be:

import click
import ccl
import pathlib

path_to_commands = pathlib.Path(__file__, "..", "commands")

my_cli = click.Group("MyCLI")
ccl.register_commands(my_cli, path_to_commands)

if __name__ == "__main__":

And voilà! All commands inside your "commands" folder have been registered!

Behind the scene

When registering commands, CCL will do the following:

  1. List files and folder inside the given source.

  2. Iterate over directory, if a file is found, go to step 3, if a folder is found, go to step 2.1

    2.1. If folder, see if a exist, if it exist, attempt to export a function that contains a click decorator (MUST BE A GROUP). If not found, create a click group, then continue to step 3 using the indicated group.

  3. If file, attempt to export a function that contains a click decorator (MUST BE A COMMAND), then add it to the given group.

  4. Continue until all files/folder have been scanned.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clickloader-0.2.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

clickloader-0.2.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page