Skip to main content

Click group wrapper for loading click commands from separate files.

Project description

Decorate the top-level--and all directory-modules' __init__ under--with the clickd decorator.

# <package-root-folder>/<cli-interface-top-level-folder>

./clickd/tests/cli  # <- this is the real test/example directory in this repo.
│   a.py
│   b.py
│   __init__.py
│
├───c
│   │   d.py
│   │   __init__.py
│   │
│   └───__pycache__
│           e.cpython-312.pyc
│           __init__.cpython-312.pyc
│
├───e
│   │   f.py
│   │   __init__.py
│   │
│   ├───g
│   │       j.py
│   │       __init__.py
│   │
│   └───h
│           k.py
│           __init__.py
│
└───__pycache__
        a.cpython-312.pyc
        b.cpython-312.pyc
        __init__.cpython-311.pyc
        __init__.cpython-312.pyc

The __init__.py files will contain @clickd(dirp=/path/to/this/inits/folder); for e.g., h/__init__.py will have:

from clickd import clickd

@clickd(dpath="./tests/cli/e/h")
def h():
    pass

And all the init-files in ./tests/cli/e/h (and ./tests/cli/e, and ./tests/cli, for that matter) will have this set-up; every click.Group that I want to automatically load subcommands as individual files from.

The subcommands will, for e.g., look like this (in this case ./test/cli/e/h/k.py):

import click

@click.command()
def k():
    print("k")

Click can be used interoperably; the only thing that won't work is the @clickd groups don't allow the use of .add_command(); I can use @click.group() as long as it is in a file found by the @clickd(dirpath=<path-to-folder-containing-file-with-group>) or it is chained by a regular instance of click.Group that eventually parents-back to the @clickd(), which is a click.MultiCommand subclass called ClickD.

I can use @click.command(cls=ClickD, dirp=<path>) above my group, instead--as a note.

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

clickd-0.1.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clickd-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file clickd-0.1.0.tar.gz.

File metadata

  • Download URL: clickd-0.1.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for clickd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d384b778c63c67af4cb49bb683751c87772d52d7198a8a4bfc808b2f26f7249
MD5 f19da8d4c6f49845e8fe60dbc2f07141
BLAKE2b-256 c7a23f63eb44cfd91a4ae3d80620bce67dfd3f856bfce67b32d253912dbac47c

See more details on using hashes here.

File details

Details for the file clickd-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clickd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for clickd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 510136bcda43ae750b512aa76f2b64813cab48f8d7f0effd51d3677649f4f862
MD5 dea258da6be8f17380c10d1946dd6693
BLAKE2b-256 7e879b26c32b6f3359dd0f2f169e880dccd1218a0d911634b71910a468044fab

See more details on using hashes here.

Supported by

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