Skip to main content

A lightweight framework for building CLI applications on top of sys.argv

Project description

cliss — A lightweight framework for building CLI applications

Python PyPI License Platform Ruff

Write type-annotated Python functions, get a full CLI — automatic --help, validation, async support, and zero dependencies.

✨ Features

  • Zero Dependencies — Pure stdlib: sys, asyncio, inspect
  • Type-Driven — Automatic arguments from function signatures and type hints
  • Flexible — Declarative Argument objects, type inference, or both
  • Async-Nativeasync def handlers with automatic event loop management
  • Global Args — Define flags shared across all commands
  • Coloured Help — Beautiful terminal output via ANSI-codes (can be disabled)
  • Bool Flags — Automatic --name/--no-name mutually exclusive group
  • Manual Parsing — Pure sys.argv parsing, no argparse dependency

🚀 Quick Start

Installation

pip install cliss

Usage

from cliss import CLI

cli = CLI(name="todo", description="Task manager", version="1.0.0")

@cli.command()
def add(task: str, priority: int = 1, done: bool = False):
    """Add a task."""
    status = "✓" if done else "○"
    return f"[{status}] {task} (priority: {priority})"

cli.run()
$ python todo.py add "Buy milk" --priority 2
[] Buy milk (priority: 2)

$ python todo.py add "Call mom" --done
[] Call mom (priority: 1)

$ python todo.py add "Test" --no-done
[] Test (priority: 1)

Disable Colours

# No colours in output
cli = CLI(name="myapp", colour=False)

# Or via environment variable
$ NO_COLOR=1 python myapp.py --help

📋 API Reference

CLI class

CLI(
    name="cli",
    description=None,
    version=None,
    colour=True,
)
Parameter Type Default Description
name str None Program name in help
description str None Description in help
version str None Adds --version flag
usage str "{self.name} [COMMAND] [OPTIONS] [ARGS]..." Custom usage string
colour bool True Enable/disable ANSI colours in output

Argument class

from cliss import Argument

Argument("--output", "-o", type=str, default=None, help="...", choices=["json","csv"], action="store_true")
Parameter Type Default Description
*flags str Argument flags
type type str Value type
default Any None Default value
help str "" Help text
required bool False Make required
choices list None Allowed values
action str None argparse action

Type → CLI Mapping

Function Signature CLI Argument
name: str Positional name
count: int = 1 --count (default: 1)
verbose: bool = False --verbose/--no-verbose
mode: str = None --mode (default: None)

📖 Examples

CRUD Application

from cliss import CLI

cli = CLI(name="db")
db = {}

@cli.command()
def set(key: str, value: str):
    db[key] = value
    return f"OK: {key} = {value}"

@cli.command()
def get(key: str):
    return db.get(key, "Not found")

@cli.command()
def delete(key: str, force: bool = False):
    if force or key in db:
        db.pop(key, None)
        return f"Deleted: {key}"
    return f"Not found (use --force)"

cli.run()

Command Groups

cli = CLI(name="git")

remote = cli.group("remote", "Manage remotes")
stash = cli.group("stash", "Stash changes")

@remote.command()
def add(name: str, url: str):
    return f"Added remote {name}"

@stash.command()
def push(message: str = ""):
    return f"Stashed: {message or 'WIP'}"

cli.run()

Async Commands

@cli.command()
async def fetch(url: str, retries: int = 3):
    return f"Fetched {url} (retries: {retries})"

❓ FAQ

Why cliss over argparse/Click/Typer/Fire?

Tool Deps Style Parser
cliss 0 Decorators + type hints sys.argv
Fire 1 (termcolor) Introspection Custom
Click 0 Decorators Custom
Typer (0.26.0+) 0 Type hints click

cliss = Fire's zero-bloat philosophy + Typer's type-driven design. Pure sys.argv parsing, custom help formatter with ANSI-colours.

Why sys.argv instead of argparse?

Manual sys.argv parsing gives complete control over argument handling, removes dependency on argparse internals, and keeps the codebase minimal. The custom parser handles flags, positional arguments, bool pairs, and type coercion directly.

Bool flags?

Automatic --name/--no-name mutually exclusive group. store_true by default, store_false if default is True.

Async?

async def handlers auto-run with asyncio.run(). Sync functions returning coroutines also work. Disable with simple=True for pure sync scripts.

Help customisation?

Full Cargo-style coloured help with HelpTheme configuration. Custom usage strings, examples sections, and per-command help registration via Help.register_command_help(). Disable colours with colour=False or NO_COLOR environment variable.

📄 License

MIT — see LICENSE file.


Author: Fkernel653 Repository: github.com/Fkernel653/cliss PyPI: pypi.org/project/cliss

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

cliss-1.1.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

cliss-1.1.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file cliss-1.1.1.tar.gz.

File metadata

  • Download URL: cliss-1.1.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cliss-1.1.1.tar.gz
Algorithm Hash digest
SHA256 28928bdd1abc05a54c1fc9d2e7bf9c75b8fcadfc3aa2c9f9ca932c9797a886b9
MD5 ddd7f880d7c42d9aecec2073625e48ee
BLAKE2b-256 c1c73c660fc6c6cce1b5f739da321d3560d1b6b10127c959ff971b8179c1aed4

See more details on using hashes here.

File details

Details for the file cliss-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: cliss-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cliss-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af581d9b99a4b5f03f19818cfc5382356685b015bc66bc6f40376277af4c8547
MD5 41b0a705174194864da8f618041bb775
BLAKE2b-256 d0fdf4932a62b725deeb47836402af9ef08af7fe6e572ee9d980b0c0932057af

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