CLI to TUI¶
Yapx offers experimental support for displaying a Textual User Interface (TUI) of your CLI.
It does this using argparse-tui, my fork of the Textualize Trogon library. To use this experimental feature:
pip install yapx[tui]
Yapx will detect the module and add a --tui
flag to your CLI.
Example¶
To create a functional app with a CLI and TUI, write this script to a file:
example-tui.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Then, make the script executable:
chmod +x ./example-tui.py
Now invoke the script:
./example-tui.py --tui
If you want the TUI to open when no arguments are provided:
yapx.run(
setup,
[say_hello, say_goodbye],
default_args=["--tui"],
)
Now you can view the TUI without giving any args:
./example-tui.py
By default, the TUI is invoked with the parameter --tui
. To use a command instead of a parameter:
yapx.run(
setup,
[say_hello, say_goodbye],
tui_flags="tui",
default_args=["tui"],
)
An example TUI could look like:
gif source: github.com/Textualize/trogon