Respond to help <term> on builtin special commands#1859
Open
rolandwalker wants to merge 1 commit intomainfrom
Open
Respond to help <term> on builtin special commands#1859rolandwalker wants to merge 1 commit intomainfrom
help <term> on builtin special commands#1859rolandwalker wants to merge 1 commit intomainfrom
Conversation
0008045 to
41fd5f2
Compare
41fd5f2 to
5ce148a
Compare
In this implementation, the detail returned is the same as visible in the table returned from a plain "help", but the change opens up the ability to add a longer help text for each special command. Motivation: there is not enough room in the tabular summary, and details such as the "-c" argument to "watch" are undocumented. Some commands, such as "watch", return longer help text when given with no argument. Others, such as "\dt", perform a default action. "help cmd" gives a uniform interface. Bugs and limitations: * "help \G" is ambiguous, so if help is desired on "\G" itself, the "\G" must be quoted. * "help use" now gives help for the mycli special command "use".
5ce148a to
4782d23
Compare
scottnemes
reviewed
Apr 26, 2026
| logger = logging.getLogger(__name__) | ||
|
|
||
| COMMANDS = {} | ||
| CASE_SENSITIVE_COMMANDS = set() |
Contributor
There was a problem hiding this comment.
Seems like this new case logic might be duplicating what already exists in register_special_command:
mycli/mycli/packages/special/main.py
Line 102 in 4782d23
scottnemes
reviewed
Apr 26, 2026
| def _show_special_help(keyword: str) -> list[SQLResult]: | ||
| header = ['name', 'description', 'example'] | ||
| description = '\n'.join(COMMANDS[keyword][2:4]) | ||
| rows = [(keyword, description, '')] |
Contributor
There was a problem hiding this comment.
Looks like the example column is always empty; is that for future use or should it be removed or populated?
scottnemes
reviewed
Apr 26, 2026
| :param command: string | ||
| """ | ||
| # special case: allow help on the \edit command | ||
| if re.match(r'^([Hh][Ee][Ll][Pp])\s+(\\e|\\edit)\s*(;|\\G|\\g)?\s*$', command): |
Contributor
There was a problem hiding this comment.
Could use re.IGNORECASE for this if desired
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In this implementation, the detail returned is the same as visible in the table returned from a plain
help, but the change opens up the ability to add a longer help text for each special command.Motivation: there is not enough room in the tabular summary, and details such as the
-cargument towatchare undocumented. Some commands, such aswatch, return longer help text when given with no argument. Others, such as\dt, perform a default action.help cmdgives a uniform interface.Bugs and limitations:
help \Gis ambiguous, so if help is desired on\Gitself, the\Gmust be quoted.help usenow gives help for the mycli special commanduse. This should be a better choice than querying the server, since the special command is what is executed.Example:
Checklist
changelog.mdfile.AUTHORSfile (or it's already there).