From f1448d65d3f9a3e499caeca5ca3ab9ecc0d0d6e1 Mon Sep 17 00:00:00 2001 From: Ramesh Padmanabhaiah <22363102+codeforester@users.noreply.github.com> Date: Wed, 5 Aug 2026 16:53:47 -0700 Subject: [PATCH] docs: add quick start example --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index ed8080d..030108c 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,35 @@ Install it with: python -m pip install base-cli ``` +## Quick start + +Create a small command with a consistent context, logging, and cleanup +lifecycle: + +```python +from __future__ import annotations + +import base_cli + + +app = base_cli.App(name="hello", version="0.1.0") + + +@app.command() +@base_cli.option("--name", default="world", show_default=True) +def hello(ctx: base_cli.Context, name: str) -> int: + ctx.log.info("greeting %s", name) + print(f"Hello, {name}!") + return base_cli.ExitCode.SUCCESS + + +if __name__ == "__main__": + raise SystemExit(base_cli.run_app(app)) +``` + +Run it with `python hello.py --name Ada`. The full lifecycle and configuration +options are documented below. + Release builds, TestPyPI rehearsals, and protected PyPI publication are documented in [`docs/releasing.md`](docs/releasing.md). The package exposes `base_cli.__version__`, which matches the distribution version.