From f11aeb04503ae8fb485c2704618c329278a5242e Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 15 Jul 2026 14:50:42 -0400 Subject: [PATCH] better ordering for /help table lexicographic by first alphabetical letter, ignoring leading punctuation. --- changelog.md | 1 + mycli/packages/special/main.py | 2 +- test/features/fixture_data/help_commands.txt | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index fcf512f1..0260bc93 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,7 @@ Features Documentation --------- * Spellcheck myclirc commentary. +* Better ordering for `/help` table. 2.2.0 (2026/07/11) diff --git a/mycli/packages/special/main.py b/mycli/packages/special/main.py index 9f852b2a..ac01c5d2 100644 --- a/mycli/packages/special/main.py +++ b/mycli/packages/special/main.py @@ -226,7 +226,7 @@ def show_help(*_args) -> list[SQLResult]: header = ["Command", "Shortcut", "Usage", "Description"] result = [] - for _, value in sorted(COMMANDS.items(), key=lambda x: str.casefold(x[0])): + for _, value in sorted(COMMANDS.items(), key=lambda x: str.casefold(x[0].removeprefix('\\').removeprefix('/'))): if value.hidden: continue if value.aliases: diff --git a/test/features/fixture_data/help_commands.txt b/test/features/fixture_data/help_commands.txt index 408125d1..2e01bab4 100644 --- a/test/features/fixture_data/help_commands.txt +++ b/test/features/fixture_data/help_commands.txt @@ -3,27 +3,26 @@ +-----------------+----------+-----------------------------------+-------------------------------------------------------------+ | /bug | | /bug | File a bug on GitHub. | | /clip | | /clip | \clip | Copy query to the system clipboard. | +| /connect | /r | /connect [database] | Reconnect to the server, optionally switching databases. | +| /delimiter | | /delimiter | Change end-of-statement delimiter. | | /dsn | | /dsn | Manage saved DSNs. | | /dt | | /dt[+] [table] | List or describe tables. | | /edit | /e | /edit | \edit | Edit query with editor (uses $VISUAL or $EDITOR). | +| /exit | /q | /exit | Exit. | | /f | | /f [name [args..]] | List or execute favorite queries. | | /fd | | /fd | Delete a favorite query. | | /fs | | /fs | Save a favorite query. | | \g | | \g | Display query results (mnemonic: go). | | \G | | \G | Display query results vertically. | +| /help | /? | /help [term] | Show this table, or search for help on a term. | | /l | | /l | List databases. | | /llm | /ai | /llm [arguments] | Interrogate an LLM. See "/llm help". | -| /once | /o | /once [-o] | Append next result to an output file (overwrite using -o). | -| /pipe_once | /| | /pipe_once | Send next result to a subprocess. | -| /timing | /t | /timing | Toggle timing of queries. | -| /connect | /r | /connect [database] | Reconnect to the server, optionally switching databases. | -| /delimiter | | /delimiter | Change end-of-statement delimiter. | -| /exit | /q | /exit | Exit. | -| /help | /? | /help [term] | Show this table, or search for help on a term. | | /nopager | /n | /nopager | Disable pager; print to stdout. | | /notee | | /notee | Stop writing results to an output file. | | /nowarnings | /w | /nowarnings | Disable automatic warnings display. | +| /once | /o | /once [-o] | Append next result to an output file (overwrite using -o). | | /pager | /P | /pager [command] | Set pager to [command]. Print query results via pager. | +| /pipe_once | /| | /pipe_once | Send next result to a subprocess. | | /prompt | /R | /prompt | Change prompt format. | | /quit | /q | /quit | Quit. | | /redirectformat | /Tr | /redirectformat | Change the table format used to output redirected results. | @@ -33,6 +32,7 @@ | /system | | /system [-r] | Execute a system shell command (raw mode with -r). | | /tableformat | /T | /tableformat | Change the table format used to output interactive results. | | /tee | | /tee [-o] | Append all results to an output file (overwrite using -o). | +| /timing | /t | /timing | Toggle timing of queries. | | /use | /u | /use | Change to a new database. | | /warnings | /W | /warnings | Enable automatic warnings display. | | /watch | | /watch [seconds] [-c] | Execute query every [seconds] seconds (5 by default). |