Skip to main content

CLIBB (Command-Line Interface Building Blocks) streamlines, simplifies and speeds up your CLI creation.

Project description

CLIBB · GitHub license

CLIBB (Command-Line Interface Building Blocks) is a Python library that streamlines, simplifies and speeds up your CLI creation. It provides eight unique and customizable building blocks to help you build a pretty, robust, and interactive CLI.

Getting Started

  1. Install CLIBB using pip by running pip install clibb.
  2. Create a new Python file in your IDE of choice.
  3. Setup window configurations using the provided building blocks detailed here.
  4. Initialize CLIBB with console = clibb.Application()
  5. Add your previously created window configurations with console.add(window_1, ...).
  6. Set the initial window with console.activate(window_1).
  7. Finally execute CLIBB and enjoy with console.run()

Documentation

Proper documentation will be provided in a future deployment. For the time being, please refer to the detailed example below and use the information provided by your IDE based on the code documentation.

Example

To help you get started without wading through the 🦆-ing boring documentation; here is a complete example that shows you everything CLIBB has to offer:

import clibb

# Example class
class Person:
    def __init__(self, name: str) -> None:
        self.__name = name
    def change_name(self) -> None:
        self.__name = "Sophie"
    def get_name(self) -> str:
        return self.__name

# Example object
adult = Person("Hannah")

# Example variables
class Settings:
    options = clibb.Mutable("Option IV")
    user_input = clibb.Mutable("Change me below!")
    checkbox_state = clibb.Mutable(True)

# Example window configuration showing all available building blocks.
window_1 = {
    "name": "Home",
    "width": 100,
    "colors": {
        "text": clibb.Color(255, 255, 255),
        "background": clibb.Color(254, 0, 0),
        "pass": clibb.Color(6, 215, 27),
        "fail": clibb.Color(255, 0, 0),
        "alert": clibb.Color(255, 255, 0),
    },
    "elements": [
        clibb.Title("CLIBB", "by Perytron with <3"),
        clibb.Separator("empty"),
        clibb.Display("How-to", "Navigate with 'w', 'a', 's', 'd'"),
        clibb.Display("", "Activate with 'q' and return with 'e'"),
        clibb.Separator("empty"),
        clibb.Display("Current Option:", Settings.options),
        clibb.Separator("empty"),
        clibb.Configuration(Settings.options,"Options:","Option I","Option II","Option III","Option IV",),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
        clibb.Display("Current Name:", adult.get_name),
        clibb.Separator("empty"),
        clibb.Action("o", "Set Name to 'Sophie'", action=adult.change_name, stealth=False),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
        clibb.Display("Current Text", Settings.user_input),
        clibb.Separator("empty"),
        clibb.Input("Input Text", Settings.user_input),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
        clibb.Display("Current Text", Settings.checkbox_state),
        clibb.Separator("empty"),
        clibb.Checkbox("Checkbox", Settings.checkbox_state),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
        clibb.Navigation("c", "Configuration", "Go to the 'Configuration' window with 'c'"),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
    ],
}

# Another example window configuration to show navigation between windows.
window_2 = {
    "name": "Configuration",
    "colors": {
        "text": clibb.Color(255, 255, 255),
        "background": clibb.Color(112, 60, 160),
        "pass": clibb.Color(0, 255, 0),
        "fail": clibb.Color(255, 0, 0),
        "alert": clibb.Color(255, 255, 0),
    },
    "elements": [
        clibb.Title("Configuration"),
        clibb.Separator("empty"),
        clibb.Navigation("h", "Home", "Go to the 'Home' window with 'h' or return with 'e'"),
        clibb.Separator("filled"),
        clibb.Separator("empty"),
    ],
}

# Setup and run CLIBB!
console = clibb.Application()
console.add(window_2, window_1)
console.remove(window_2)
console.add(window_2)
console.activate(window_1)
console.run()

Contributing

I'd love to collaborate with you! Feel free to fork this repository, implement or refactor as desired, and create a pull request for integration into the main branch. If you encounter any issues or have questions, open an issue, and I'll be happy to assist.

CLIBB is GPL-3.0 licensed.

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

clibb-0.3.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

clibb-0.3.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file clibb-0.3.0.tar.gz.

File metadata

  • Download URL: clibb-0.3.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for clibb-0.3.0.tar.gz
Algorithm Hash digest
SHA256 851a0fd9f02efe291de644ae3f97f92b8fb35e67aa6efb6edcfe17e3d66037f8
MD5 cc5ff1c632d5c100cb3f122f5d0c3e58
BLAKE2b-256 d30e804d1d64a0efc7163b6746b4d90f124ea56ca6059f3c62b31b4aa94bb0a1

See more details on using hashes here.

File details

Details for the file clibb-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: clibb-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for clibb-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 044492e0775f5b22571214e0d10aef91cc4779cb86d12217f92032f9fe346141
MD5 ae7b761211e58160756ad6e2d48ca1f2
BLAKE2b-256 39f115e25f3e1620a7846a93db0c471fcba1876920c11988012105494ce692e5

See more details on using hashes here.

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