1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

psql: Add documentation URL to \help output

Add a link to the specific command's reference web page to the bottom
of its \help output.

Discussion: https://www.postgresql.org/message-id/flat/40179bd0-fa7d-4108-1991-a20ae9ad5667%402ndquadrant.com
This commit is contained in:
Peter Eisentraut
2019-03-11 08:50:02 +01:00
parent f2d84a4a6b
commit 27f3dea648
2 changed files with 17 additions and 4 deletions

View File

@ -623,16 +623,23 @@ helpSQL(const char *topic, unsigned short int pager)
strcmp(topic, "*") == 0)
{
PQExpBufferData buffer;
char *url;
initPQExpBuffer(&buffer);
QL_HELP[i].syntaxfunc(&buffer);
help_found = true;
url = psprintf("https://www.postgresql.org/docs/%s/%s.html",
strstr(PG_VERSION, "devel") ? "devel" : PG_MAJORVERSION,
QL_HELP[i].docbook_id);
fprintf(output, _("Command: %s\n"
"Description: %s\n"
"Syntax:\n%s\n\n"),
"Syntax:\n%s\n\n"
"URL: %s\n\n"),
QL_HELP[i].cmd,
_(QL_HELP[i].help),
buffer.data);
buffer.data,
url);
free(url);
/* If we have an exact match, exit. Fixes \h SELECT */
if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0)
break;