sprezzature-cli-gui
Turn any Python command-line tool into a clickable form, automatically. A command-line tool takes typed text ("do this, with these options") instead of buttons and fields; this package reads the tool's own definition of its commands and options and builds a web page with a button and a field for each one, so a person who has never opened a terminal can still use it.
Point this tool at a parser: the object inside a Python CLI that reads and validates
the typed command. argparse (in Python's standard library), Click, and Typer are
the three common ways to build one; all three are supported. Given that parser, this
package emits a single self-contained page written in plain JavaScript and styled with
Tailwind (a CSS framework, meaning it ships pre-made style classes instead of hand-
written CSS). Every sub-command becomes a section, every flag a field. The page never
runs the command itself: it assembles the exact command line as text, in the visitor's
own browser, ready to copy and paste, to hand to a desktop app through a Tauri
invoke call (Tauri wraps a web page as a native desktop app; invoke is how
that wrapper lets the page call back into it), or to send to a FastAPI endpoint (a small
Python web server) that runs it for real.
For example: a CLI with a --verbose flag and a convert INPUT OUTPUT sub-command
becomes a page with a checkbox for --verbose and two text fields for INPUT and
OUTPUT; filling them in and pressing "Build command" prints the exact line
mytool convert in.csv out.json --verbose for the visitor to copy.
No framework, no build step: the emitted page is one static HTML file. It does load
Tailwind's "Play" build from a CDN (cdn.tailwindcss.com) to turn the utility classes
into real CSS in the visitor's browser, so opening the file needs an internet
connection the first time; the form fields themselves still work, unstyled, without one.
Install
pip install sprezzature-cli-gui # core (argparse)
pip install "sprezzature-cli-gui[click]" # add Click support
pip install "sprezzature-cli-gui[typer]" # add Typer support
Use
# From a parser factory in an importable module
sprezzature-cli-gui my_pkg.my_cli:build_parser > gui.html
# From a script path
sprezzature-cli-gui ./my_cli.py:make_parser > gui.html
When the parser cannot be imported, the tool falls back to parsing the tool's --help
output, so it works even against a CLI it cannot introspect directly, including one
that is not written in Python at all.
How it works
cli_to_gui.py is a thin wrapper that re-exports the real implementation, which lives
in the sprezzature_cli_gui package:
adapters/: read (introspect, meaning: examine the parser object's own fields directly, rather than guess from printed text) an argparse or Click parser; or, when no parser object is reachable, fall back to parsing the tool's--helptext instead.schema.py: the one normalized command/flag description every adapter produces, so the renderer never needs to know which of the three frameworks it came from.renderer.py: turns that description into the self-contained HTML + Tailwind + plain-JavaScript page.loader.py: resolves amodule:factoryorpath.py:factoryspec (a string naming where the parser-building function lives) down to the actual parser object.
License
BSD-3-Clause © Warith HARCHAOUI. Part of the sprezzature toolkit.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sprezzature_cli_gui-1.0.0.tar.gz.
File metadata
- Download URL: sprezzature_cli_gui-1.0.0.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3f7fbd4a11c443493914fd1a66ebd534904f6819d82f557c4ada9d080caa37c
|
|
| MD5 |
a825a2865971e902d8fdf6530b0f7e4a
|
|
| BLAKE2b-256 |
28e236fddf32300c51d81aef9eb818f7bf588d87d31b83fec5686d54c6ca3229
|
File details
Details for the file sprezzature_cli_gui-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sprezzature_cli_gui-1.0.0-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68d4ed8066a0de86389efd17fc8b714703b8420e6561b4fe38669f9e23cd5ccf
|
|
| MD5 |
0c3e46572f4d70fed91e13f2c3dd63a4
|
|
| BLAKE2b-256 |
757ddefe15a4e1b996a4116b8b37d3c544729b8965465b18644a2765dad144d2
|