Skip to main content

A Python framework for making CLI tools prettier and customizable.

Project description

SaiunCLI ✨

SaiunCLI is a Python framework for creating visually appealing, user-friendly, and highly customizable Command-Line Interface (CLI) tools. It leverages the power of rich for styling and formatting, making it easy to build modern CLI applications that are both functional and beautiful.

Inspired by rich-cli.

preview image

Project Status: 🚧 Under Construction 🚧

SaiunCLI is actively being developed. Some features may be incomplete or subject to change. Stay tuned for updates and improvements!

Features

  • Customizable Themes: Easily style your CLI with themes and override defaults.
  • Command and Subcommand Support: Define commands and nested subcommands with specific options and arguments.
  • Inherited Options and Arguments: Configure options to be inherited across subcommands.
  • Global Options: Define options that apply globally across all commands and subcommands.
  • Modern Styling: Leverage rich to make CLI output visually appealing, including tables, progress bars, and spinners.
  • User-Friendly Argument Parsing: Parse both positional arguments and flags in a structured and intuitive manner.
  • Dynamic Command Registration: Add commands programmatically during runtime.
  • Configurable Help and Usage: Auto-generate help messages for commands with customization options.
  • Intuitive Developer Experience: Focus on functionality without worrying about low-level details.

Comparison with Other Tools

Feature SaiunCLI Click Argparse
Custom Styling
Nested Commands
Dynamic Commands
Option Inheritance
Global Options
Easy Theming

Installation

You can install saiuncli with pip.

pip install saiuncli

Usage

from saiuncli.cli import CLI
from saiuncli.command import Command
from saiuncli.option import Option
from saiuncli.theme import Theme

# Custom theme and console for CLI outputs
theme = Theme()
console = Console(theme=theme)


def hello_handler(name: str, count: int):
    for i in range(count):
        console.print(f"Hello, {name}!")
    console.success("Succcessfully executed handler!")


def count_handler(a: int, b: int):
    if a is None or b is None:
        raise ValueError("Both 'a' and 'b' must be provided.")
    console.print(f"{a} + {b} = {a + b}")
    console.success("Succcessfully executed handler!")


def base_handler(**args):
    console.print("Base command executed.")
    if args:
        console.print(f"{args}")

    console.success("Success Message")
    console.error("Error Message")
    console.warning("Warning Message")
    console.info("Info Message")


if __name__ == "__main__":

    # Create CLI
    mycli = CLI(
        title="My Super Cool CLI Tool",
        description="A simple tool to demonstrate saiuncli.",
        version="1.0.0",
        console=console,
        handler=base_handler, # Command Handler
        help_flags=[],
        version_flags=[],
        options=[
            Option(
                flags=["-v", "--verbose"],
                description="Enable verbose output.",
                action="store_true",
            ),
            Option(
                flags=["-q", "--quiet"],
                description="Enable quiet output.",
                action="store_true",
            ),
            Option(
                flags=["-d", "--debug"],
                description="Enable debug output.",
                action="store_true",
            ),
        ],
    )

    # Define Subcommands
    hello_command = Command(
        name="hello",
        handler=hello_handler,
        description="Prints 'Hello, world!' to the console.",
        options=[
            Option(
                flags=["-n", "--name"],
                description="The name to print.",
                type=str,
                required=True,
            ),
            Option(
                flags=["-c", "--count"],
                description="The number of times to print the name.",
                type=int,
                default=1,
            ),
        ],
    )

    count_command = Command(
        name="count",
        handler=count_handler,
        description="Adds two numbers together.",
        options=[
            Option(
                flags=["-a"],
                description="The first number.",
                type=int,
                required=True,
            ),
            Option(
                flags=["-b"],
                description="The second number.",
                type=int,
                required=True,
            ),
        ],
    )


    # Append Subcommands
    mycli.add_subcommands([hello_command, count_command])

    # Run your CLI Tool!
    mycli.run()

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

saiuncli-0.1.10.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

saiuncli-0.1.10-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file saiuncli-0.1.10.tar.gz.

File metadata

  • Download URL: saiuncli-0.1.10.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for saiuncli-0.1.10.tar.gz
Algorithm Hash digest
SHA256 5f6aea729700344fb6c95d12e3ca0802c403a9cc15108f863c09905ef389ee13
MD5 790e8149e179a55c6c3469ee6966afbb
BLAKE2b-256 3929c7a6d33827749cab8782f91d0d24f43bbbc2e0ad0547c20938d111aa8273

See more details on using hashes here.

File details

Details for the file saiuncli-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: saiuncli-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for saiuncli-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 724a0b55a27c041870e4312e880d037f46563bc057c3916906f4f7b5f0eebd2b
MD5 a52f7f230869434309bfbe28c8475436
BLAKE2b-256 b6953dcb33d9eb1247fad225f5944a5bef4e02f27efecb8c2e9ada7c791abcda

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