Compare commits

...

8 commits

Author SHA1 Message Date
Simon Willison
5587da085d Release 3.32
Refs #544, #545, #547, #548
2023-05-21 11:53:33 -07:00
Simon Willison
948692a94b only run flake8 on Python 3.8 or higher, refs #550 2023-05-21 11:26:27 -07:00
Simon Willison
e4cff2236b Ignore trogon mypy error 2023-05-21 11:14:34 -07:00
Simon Willison
c4fec77eea It's trogon not trogan 2023-05-21 10:59:08 -07:00
Simon Willison
0ac8ca972b Fixed command documentation test for tui 2023-05-21 10:57:42 -07:00
Simon Willison
f3120f06a3 Screenshot of TUI, refs #545 2023-05-21 10:55:19 -07:00
Simon Willison
b1a2bb1dbf Documentation for trogon TUI, refs #545 2023-05-21 10:54:54 -07:00
Simon Willison
ec12b780d5 sqlite-utils tui command if Trogon is installed, refs #545 2023-05-21 07:10:20 -07:00
9 changed files with 68 additions and 5 deletions

View file

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

View file

@ -28,7 +28,7 @@ jobs:
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[test,mypy,flake8]'
pip install -e '.[test,mypy,flake8,tui]'
- name: Optionally install numpy
if: matrix.numpy == 1
run: pip install numpy
@ -44,7 +44,8 @@ jobs:
pytest -v
- name: run mypy
run: mypy sqlite_utils tests
- name: run flake8
- name: run flake8 if Python 3.8 or higher
if: matrix.python-version >= 3.8
run: flake8
- name: Check formatting
run: black . --check

BIN
docs/_static/img/tui.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

View file

@ -4,6 +4,18 @@
Changelog
===========
.. _v3_32:
3.32 (2023-05-21)
-----------------
- New experimental ``sqlite-utils tui`` interface for interactively building command-line invocations, powered by `Trogon <https://github.com/Textualize/trogon>`__. This requires an optional dependency, installed using ``sqlite-utils install trogon``. There is a screenshot :ref:`in the documentation <cli_tui>`. (:issue:`545`)
- ``sqlite-utils analyze-tables`` command (:ref:`documentation <cli_analyze_tables>`) now has a ``--common-limit 20`` option for changing the number of common/least-common values shown for each column. (:issue:`544`)
- ``sqlite-utils analyze-tables --no-most`` and ``--no-least`` options for disabling calculation of most-common and least-common values.
- If a column contains only ``null`` values, ``analyze-tables`` will no longer attempt to calculate the most common and least common values for that column. (:issue:`547`)
- Calling ``sqlite-utils analyze-tables`` with non-existent columns in the ``-c/--column`` option now results in an error message. (:issue:`548`)
- The ``table.analyze_column()`` method (:ref:`documented here <python_api_analyze_column>`) now accepts ``most_common=False`` and ``least_common=False`` options for disabling calculation of those values.
.. _v3_31:
3.31 (2023-05-08)

View file

@ -61,6 +61,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
"create-spatial-index": "cli_spatialite_indexes",
"install": "cli_install",
"uninstall": "cli_uninstall",
"tui": "cli_tui",
}
commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999)
cog.out("\n")
@ -1022,6 +1023,23 @@ disable-fts
-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:
optimize

View file

@ -2159,3 +2159,25 @@ You can uninstall packages that were installed using ``sqlite-utils install`` wi
$ sqlite-utils uninstall beautifulsoup4
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 `Trogon <https://github.com/Textualize/trogon/>`__ TUI library.
To enable this feature you will need to install the ``trogon`` dependency. You can do that like so::
sqite-utils install trogon
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

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
import io
import os
VERSION = "3.31"
VERSION = "3.32"
def get_long_description():
@ -47,6 +47,7 @@ setup(
"data-science-types",
],
"flake8": ["flake8"],
"tui": ["trogon"],
},
entry_points="""
[console_scripts]

View file

@ -33,6 +33,11 @@ from .utils import (
TypeTracker,
)
try:
import trogon # type: ignore
except ImportError:
trogon = None
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
@ -112,6 +117,10 @@ def cli():
pass
if trogon is not None:
cli = trogon.tui()(cli)
@cli.command()
@click.argument(
"path",

View file

@ -5,7 +5,7 @@ import pytest
import re
docs_path = Path(__file__).parent.parent / "docs"
commands_re = re.compile(r"(?:\$ | )sqlite-utils (\S+) ")
commands_re = re.compile(r"(?:\$ | )sqlite-utils (\S+)")
recipes_re = re.compile(r"r\.(\w+)\(")