treeparse

Getting Started

Install treeparse and build your first tree CLI.

Getting Started

Installation

# From git (recommended during active dev)
pip install git+https://github.com/wr1/treeparse

# Or with uv (dev workflow)
uv add git+https://github.com/wr1/treeparse

For local development on the repo:

cd treeparse
uv sync
uv run --with-editable . python examples/basic.py

See the README and examples/ for the exact dev command pattern.

Your First CLI

Create mycli.py:

from __future__ import annotations

from treeparse import cli, command, argument, option


def build(src: str, out: str | None = None, verbose: bool = False) -> None:
    """Build something."""
    print(f"Building {src} -> {out or 'default'} (verbose={verbose})")


app = cli(
    name="mycli",
    help="My example CLI.",
    commands=[
        command(
            name="build",
            help="Build the thing.",
            callback=build,
            arguments=[argument(name="src", arg_type=str, help="Source path.")],
            options=[
                option(flags=["--out", "-o"], arg_type=str, help="Output path."),
                option(flags=["--verbose", "-v"], flag=True, help="Verbose output."),
            ],
        ),
    ],
)

if __name__ == "__main__":
    app.run()

Run:

python mycli.py build input.txt -o dist/ -v
python mycli.py build --help

The help output renders as a tree.

Using Groups

from treeparse import cli, group, command, argument

ops = group(name="ops", help="Operations.")
ops.commands.append(
    command(name="status", help="Show status.", callback=..., arguments=[...])
)

app = cli(name="app", help="Main app.")
app.subgroups.append(ops)

Development Workflow (Docs-Driven)

This project uses docs-based development with the fumano/DocKB setup (latest practice):

  • Public docs live only in docs/docs/*.mdx
  • kb/ lives at the Fumadocs site root (docs/kb/, next to app/). It is its own git repository.
  • To run the docs site (rich mode when docs/kb/ exists): make docs-dev (local Makefile) or npm --prefix docs install && npm --prefix docs run dev
  • Leave timestamped JSON comments in docs/kb/comments/.
  • Agents/humans monitor kb/comments/, read the referenced docs/docs/... file, act (edit docs or code), then resolve the comment JSON and commit inside the kb/ repo.

See:

  • The CLAUDE.md and project rules at repo root.
  • DocKB internals (rich mode): available under /dev/ when kb/ present (includes architecture, agent guide, commenting).

Next Steps

  • Read the model docs: cli, command etc.
  • Browse examples
  • Run the test suite: uv run pytest
  • Before PRs: ruff check --fix && ruff format && uv run pytest

On this page