Skip to main content

Minimal command-line interface using a plugin-based architecture

This project demonstrates a minimal (but featureful) command-line interface (CLI) using a plugin-based architecture (PBA). The CLI itself is constructed using Typer.

The PBA is achieved using a combination of:

For a working plugin example, see minimal-pba-cli-plugin-example.

Installation

Install the core CLI using the following command:

$ pipx install minimal-pba-cli

Usage

List available commands using the help:

$ pba-cli --help

Plugins

List available plugins using the following command (requires a Libraries.io API key):

LIBRARIES_IO_API_KEY=<your API key> pba-cli plugin catalog

Install a plugin using the following command:

$ pba-cli plugin install <plugin name>

List installed plugins using the following command:

$ pba-cli plugin list

Install a plugin from a local directory using the following command:

$ pba-cli plugin install-local <path to plugin directory>

Uninstall a plugin using the following command:

$ pba-cli plugin uninstall <plugin name>

Custom scripts

To create a custom script that registers in the CLI, create an executable anywhere on your PATH that follows the naming convention minimal-pba-cli-<name>. This script will be registered as a command named <name> in the CLI.

As an example, create a script named minimal-pba-cli-hello with the following content:

#!/usr/bin/env sh

echo "Hello, world!"

Make the script executable:

$ chmod +x minimal-pba-cli-hello

Now, if the script is located in a directory on your PATH, you can run it using the following command:

$ pba-cli hello
Hello, world!

Scripts can be written in any language, as long as they are executable and follow the naming convention:

#!/usr/bin/env python

# minimal-pba-cli-quote

import json
import urllib.request


if __name__ == "__main__":
    response = urllib.request.urlopen("https://zenquotes.io/api/random")
    data = json.loads(response.read().decode("utf-8"))
    print(f"""
"{data[0]['q']}"

- {data[0]['a']}
$ pba-cli quote

"Educating the mind without educating the heart is no education at all."

- Aristotle

Metadata

Release files for minimal-pba-cli 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minimal-pba-cli 0.0.5
File Size Uploaded
minimal_pba_cli-0.0.5.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minimal-pba-cli 0.0.5
File Interpreter ABI Platform
minimal_pba_cli-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / minimal_pba_cli-0.0.5.tar.gz

Download URL minimal_pba_cli-0.0.5.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
609586da1ddeafb900802043eed8aba27f59e2521af8bb1eb4b3d6ccd2927990
BLAKE2b-256 checksum
How to use checksums
b8db1b255e1295016c43bdb2006cc3c529bbafdc12c93324c742d8e3c244347b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / minimal_pba_cli-0.0.5-py3-none-any.whl

Download URL minimal_pba_cli-0.0.5-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11ece826d926401ced28b01cc2921ffe5fd7421b8391ec5f720d1eff51fb3210
BLAKE2b-256 checksum
How to use checksums
4ee50bc2653a7ff8643707170623a764acbb9a4938e27d8cbec1c9ff38a48cfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page