Respond to help <term> on builtin special commands#1859
Respond to help <term> on builtin special commands#1859rolandwalker wants to merge 1 commit intomainfrom
help <term> on builtin special commands#1859Conversation
0008045 to
41fd5f2
Compare
5ce148a to
4782d23
Compare
| logger = logging.getLogger(__name__) | ||
|
|
||
| COMMANDS = {} | ||
| CASE_SENSITIVE_COMMANDS = set() |
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
There was a problem hiding this comment.
Yes, this is leveraging the same information, to make it possible to immediately and accurately look up a command, respecting case-sensitivity, in one step.
| def _show_special_help(keyword: str) -> list[SQLResult]: | ||
| header = ['name', 'description', 'example'] | ||
| description = '\n'.join(COMMANDS[keyword][2:4]) | ||
| rows = [(keyword, description, '')] |
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?
There was a problem hiding this comment.
The columns are made to match the output of help when returned from the server. See help SELECT;. Yes, I hope to populate the examples where appropriate.
| :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): |
There was a problem hiding this comment.
Could use re.IGNORECASE for this if desired
There was a problem hiding this comment.
Unfortunately \edit is case-sensitive, though I don't know why it must be.
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".
4782d23 to
f34c1e5
Compare
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).