Skip to main content

A humane CLI application framework

Project description

lionscliapp

A humane CLI application framework for Python.

lionscliapp removes the argument-parsing tax from CLI tool development while providing persistent per-project configuration, typed option namespaces, and a clean execution model. It emphasizes inspectability, clarity, and long-lived tooling.

Features

  • Declarative Application Structure — Declare commands, options, and descriptions through a simple API
  • Persistent Per-Project Configuration — Each project maintains a .json config file that survives across invocations
  • Configuration Layering — Values merge from defaults → disk config → options file → CLI overrides
  • Namespace-Based Type Coercion — Automatic conversion based on key prefixes:
    • path.*pathlib.Path
    • json.rendering.* → enum ("pretty", "compact")
    • json.indent.* → integer ≥ 0
  • Built-in Commandsset, get, and help provided out of the box
  • Two-Phase CLI Parsing — Framework options parsed separately from command arguments
  • JSON as Universal Substrate — All declarative data is JSON-serializable

Installation

Requires Python 3.10+.

pip install -e .

Quick Start

import lionscliapp as app

# Declare app identity
app.declare_app("mytool", "1.0")
app.describe_app("A tool that does useful things")

# Declare project directory for persistent config
app.declare_projectdir(".mytool")

# Declare configuration keys with defaults
app.declare_key("path.output", "/tmp/output")
app.declare_key("json.indent.data", 2)

# Define and bind commands
def run_command():
    output_path = app.ctx["path.output"]  # Already a pathlib.Path
    print(f"Output will go to: {output_path}")

app.declare_cmd("run", run_command)
app.describe_cmd("run", "Run the main process")

# Start the application
app.main()

CLI Usage

# Show help
mytool help

# Run a user-defined command
mytool run

# Set a persistent config value
mytool set path.output /new/path

# Get a config value
mytool get path.output

# Override options via CLI (transient)
mytool --path.output /tmp run

# Load overrides from a JSON file
mytool --options-file overrides.json run

# Override execution root
mytool --execroot /other/project run

Project Structure

src/lionscliapp/
├── __init__.py        # Public API exports
├── application.py     # Application data model
├── declarations.py    # Declaration API (declare_app, declare_cmd, etc.)
├── entrypoint.py      # Main entry point and lifecycle
├── dispatch.py        # Command dispatch
├── builtins.py        # Built-in commands (set, get, help)
├── ctx.py             # Runtime context construction
├── cli_parsing.py     # Two-phase CLI parsing
├── config_io.py       # Config file I/O
├── execroot.py        # Execution root resolution
└── ...

Status

Version: 0.1.0 (v0 specification)

Core framework is complete with:

  • Full lifecycle management
  • Command dispatch with exit codes
  • Built-in commands
  • Configuration layering and persistence
  • Type coercion

Future plans include programmatic invocation (app.run()), interactive config editing, and extensible namespace registration.

License

See LICENSE file for details.

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

lionscliapp-0.1.0.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

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

lionscliapp-0.1.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lionscliapp-0.1.0.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lionscliapp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a81313e3562e7a9a96f8f4d2e252ebc2448830ca2d7b98d752e2b0f0c9c4018
MD5 66ac9adf4b24582d08e0d43d96712d71
BLAKE2b-256 b51db105522528f0f9b15520b9b3f906a86064712e00fa6574b032c06c917edb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lionscliapp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lionscliapp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e6f1d5fddfd18fc3ad0a8e7c37b4b1f1e77aa223e967f094aa998f115ed5126
MD5 dcd60538ace3e536bdd49e8a2cf254ba
BLAKE2b-256 89514814e251bd771dc07fa675e1a37007fa7034c41bb43f13878a5d4886505c

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