Documentation for trogon TUI, refs #545

This commit is contained in:
Simon Willison 2023-05-21 10:53:22 -07:00
commit b1a2bb1dbf
5 changed files with 43 additions and 2 deletions

View file

@ -26,7 +26,7 @@ jobs:
${{ runner.os }}-pip- ${{ runner.os }}-pip-
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -e '.[test]' pip install -e '.[test,tui]'
- name: Run tests - name: Run tests
run: | run: |
pytest pytest

View file

@ -28,7 +28,7 @@ jobs:
${{ runner.os }}-pip- ${{ runner.os }}-pip-
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -e '.[test,mypy,flake8]' pip install -e '.[test,mypy,flake8,tui]'
- name: Optionally install numpy - name: Optionally install numpy
if: matrix.numpy == 1 if: matrix.numpy == 1
run: pip install numpy run: pip install numpy

View file

@ -61,6 +61,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
"create-spatial-index": "cli_spatialite_indexes", "create-spatial-index": "cli_spatialite_indexes",
"install": "cli_install", "install": "cli_install",
"uninstall": "cli_uninstall", "uninstall": "cli_uninstall",
"tui": "cli_tui",
} }
commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999) commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999)
cog.out("\n") cog.out("\n")
@ -1022,6 +1023,23 @@ disable-fts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_tui:
tui
===
See :ref:`cli_tui`.
::
Usage: sqlite-utils tui [OPTIONS]
Open Textual TUI.
Options:
-h, --help Show this message and exit.
.. _cli_ref_optimize: .. _cli_ref_optimize:
optimize optimize

View file

@ -2159,3 +2159,25 @@ You can uninstall packages that were installed using ``sqlite-utils install`` wi
$ sqlite-utils uninstall beautifulsoup4 $ sqlite-utils uninstall beautifulsoup4
Use ``-y`` to skip the request for confirmation. Use ``-y`` to skip the request for confirmation.
.. _cli_tui:
Experimental TUI
================
A TUI is a "text user interface" (or "terminal user interface") - a keyboard and mouse driven graphical interface running in your terminal.
``sqlite-utils`` has experimental support for a TUI for building command-line invocations, built on top of the `Trogan <https://github.com/Textualize/trogon/>`__ TUI library.
To enable this feature you will need to install the ``trogan`` dependency. You can do that like so::
sqite-utils install trogan
Once installed, running the ``sqlite-utils tui`` command will launch the TUI interface::
sqlite-utils tui
You can then construct a command by selecting options from the menus, and execute it using ``Ctrl+R``.
.. image:: _static/img/tui.png
:alt: A TUI interface for sqlite-utils - the left column shows a list of commands, while the right panel has a form for constructing arguments to the add-column command.

View file

@ -47,6 +47,7 @@ setup(
"data-science-types", "data-science-types",
], ],
"flake8": ["flake8"], "flake8": ["flake8"],
"tui": ["trogon"],
}, },
entry_points=""" entry_points="""
[console_scripts] [console_scripts]