CLI & scaffolding
Goal
Use the streamtree Typer CLI for run, tree, doctor, and init templates
without memorizing python -m streamlit flags.
Install
Commands
| Command | Purpose |
|---|---|
streamtree run app.py … |
Forwards argv to python -m streamlit run (exit code preserved). |
streamtree preview / serve |
Aliases of run (same forwarding). |
streamtree doctor |
Prints StreamTree, Streamlit, Python, Typer presence. --verbose adds runtime + introspection hints. |
streamtree tree module:attr |
Dumps render_to_tree JSON / text / Mermaid; --summarize, --expand-components (needs Streamlit runtime). |
streamtree init [dir] |
Writes app.py; --with-pages, --template / -t, --force, --name. |
Scaffold templates
Templates: default, crud, explore, enterprise (see streamtree.helpers.scaffold).
Operator notes
Markdown runbook shipped with examples:
# Running StreamTree examples with the optional CLI
Install Typer via the **`[cli]`** extra (see `pyproject.toml`):
```bash
pip install "streamtree[cli]"
The streamtree script delegates to Streamlit’s own CLI:
streamtree run examples/counter.py
streamtree run examples/numeric_nav_demo.py -- --server.headless true
streamtree run examples/pages_helpers_demo.py
Arguments after the script path are forwarded unchanged to python -m streamlit run …. The working directory and exit code are those of the child process.
For support or bug reports, run:
This prints streamtree, streamlit, and Python versions, and whether Typer is importable.
Scaffolding a new app (streamtree init)
Generate app.py (and optionally pages/) in the current directory or under a target path:
Or pass a directory explicitly:
Use --force to overwrite existing generated files. --name sets the App.page_title string in the template.
Templates (0.10.0+): --template (short -t) selects the generated app.py body:
| Value | Purpose |
|---|---|
default |
Current multipage-aware shell (same as omitting --template) |
crud |
Routes + streamtree.crud.save_intent_counter starter |
explore |
column_summary on in-memory rows + Markdown preview |
enterprise |
app_context.provider + streamtree.enterprise event sink stub |
Examples:
streamtree init myapp --template crud --name "My CRUD"
streamtree init myapp -t explore
streamtree init myapp --template enterprise --force
The always-supported path remains:
```