Safe, Pythonic bindings for the sparcli C library – styled terminal output (panels, tables, rules, lists, trees, columns, progress bars, spinners, markup) and interactive input widgets (confirm, text/password/number/ textarea, select, fuzzy finder, date picker).
Built with cffi in API mode: a small C extension is compiled from the vendored sparcli C sources, so installing needs only a C compiler – no prior make and no system-installed library.
import sparcli as sc
sc.panel("Hello", sc.PanelOpts(title="greeting", full_width=True))
t = sc.Table()
t.column("Name").column("Age", sc.ColOpts(halign=sc.Align.RIGHT))
t.row(["Ada", "36"]).row(["Alan", "41"])
t.print(sc.TableOpts(header_row=True, striped=True))
name = sc.text_input("Your name") # -> str, or None if cancelled (Esc/Ctrl-C)Interactive widgets return their value on success, None on cancel, and raise sparcli.SparcliInputUnavailable when there is no terminal.
From the repo root:
make python # build the extension in place (src/sparcli/_sparcli_cffi.*)
make python-test # build + run the non-interactive pytest suitemake uses python3; point it at an interpreter that has cffi with make python PY=/path/to/python. To install into an environment instead:
pip install cffi setuptools wheel
pip install --no-build-isolation -e bindings/python(An editable (-e) install with build isolation off: the C sources live in the repo, reached via the in-tree csrc/cinclude symlinks, so the build must run in place – an isolated or out-of-tree wheel build would lose them.)
Examples live in the repo-wide examples/python/ tree, grouped by area; the
full cross-language list is in docs/examples.md.
# from the repo root, after `make python`:
PYTHONPATH=bindings/python/src python examples/python/output/table_basic.py
PYTHONPATH=bindings/python/src python examples/python/input/fuzzy.py # needs a terminal
# or, for any language: make run-example EX=python/output/table_basicSee docs/api-python.md for the full reference.