Automatically generate a Textual TUI for your Click CLI
Project description
Trogon
Auto-generate friendly terminal user interfaces for command line apps.
🎬 Video demonstration
A quick tour of a Trogon app applied to sqlite-utils.
https://github.com/Textualize/trogon/assets/554369/c9e5dabb-5624-45cb-8612-f6ecfde70362
Trogon works with the popular Click library for Python, but will support other libraries and languages in the future.
How it works
Trogon inspects your (command line) app and extracts a schema which describes the options / switches / help etc. It then uses that information to build a Textual UI you can use to edit and run the command.
Ultimately we would like to formalize this schema and a protocol to extract or expose it from apps. This which would allow Trogon to build TUIs for any CLI app, regardless of how it was built. If you are familiar with Swagger, think Swagger for CLIs.
Screenshots
Why?
Command line apps reward repeated use, but they lack in discoverability. If you don't use a CLI app frequently, or there are too many options to commit to memory, a Trogon TUI interface can help you (re)discover options and switches.
What does the name mean?
This project started life as a Textual experiment, which we have been giving birds' names to. A Trogon is a beautiful bird I was lucky enough to photograph in 2017.
See also Frogmouth, a Markdown browser for the terminal.
Roadmap
Trogon is usable now. It is only 2 lines (!) of code to add to an existing project.
It is still in an early stage of development, and we have lots of improvements planned for it.
Installing
Trogon may be installed with PyPI.
pip install trogon
Quickstart
Click
- Import
from trogon import tui
- Add the
@tui
decorator above your click app, e.g.from trogon import tui @tui() @click.group(...) def cli(): ...
- Your click app will have a new
tui
command available.
Typer
- Import
from trogon.typer import init_tui
- Pass your Typer CLI app into the
init_tui
function, e.g.cli = typer.Typer(...) init_tui(cli)
- Your Typer app will have a new
tui
command available.
See also the examples
folder for two example apps.
Custom command name and custom help
By default the command added will be called tui
and the help text for it will be Open Textual TUI.
You can customize one or both of these using the command=
and help=
parameters:
@tui(command="ui", help="Open terminal UI")
@click.group(...)
def cli():
...
Follow this project
If this app interests you, you may want to join the Textual Discord server where you can talk to Textual developers / community.
Project details
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
File details
Details for the file trogon-0.6.0.tar.gz
.
File metadata
- Download URL: trogon-0.6.0.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.5 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd1abfeb7b15d79d6e6cfc9e724aad2a2728812e4713a744d975f133e7ec73a4 |
|
MD5 | 58f8b25d86d951a52e0a9f807b500f07 |
|
BLAKE2b-256 | cfae7367acac2194a215b092ba3fccde3b558272702110b8bb9bea164ab4ac42 |
File details
Details for the file trogon-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: trogon-0.6.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.5 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb5b6c25acd7a0eaba8d2cd32a57f1d80c26413cea737dad7a4eebcda56060e0 |
|
MD5 | 32f924c22740f7a88966bd774637e6b2 |
|
BLAKE2b-256 | 973033035d5796a3b8b9624997fec7545e3febd2268c7b48df38a715a95cb5e4 |