summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2008-04-04 17:42:43 +0000
committerBruce Momjian2008-04-04 17:42:43 +0000
commita5a68b6fb2e1dea8b1831091144465f400980783 (patch)
tree69e38e17f323db62878429c45fca56ccb778fea2
parent73552a70387803be378b0fd64dcca389d1c401b6 (diff)
Allow 'help' in psql to show \? help, for novice assistance.
Greg Sabino Mullane
-rw-r--r--src/bin/psql/help.c1
-rw-r--r--src/bin/psql/mainloop.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 8d3b24368d..792c4eea22 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -188,6 +188,7 @@ slashUsage(unsigned short int pager)
ON(pset.timing));
fprintf(output, _(" \\unset NAME unset (delete) internal variable\n"));
fprintf(output, _(" \\! [COMMAND] execute command in shell or start interactive shell\n"));
+ fprintf(output, _(" \\? display this help output\n"));
fprintf(output, "\n");
fprintf(output, _("Query Buffer\n"));
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 5ea3cfd8c8..ab0743a853 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -11,6 +11,7 @@
#include "command.h"
#include "common.h"
+#include "help.h"
#include "input.h"
#include "settings.h"
@@ -171,6 +172,16 @@ MainLoop(FILE *source)
continue;
}
+ /* A request for help? Be friendly and show them the slash way of doing things */
+ if (pset.cur_cmd_interactive && query_buf->len == 0 &&
+ pg_strncasecmp(line, "help", 4) == 0 &&
+ (line[4] == '\0' || line[4] == ';' || isspace(line[4])))
+ {
+ free(line);
+ slashUsage(pset.popt.topt.pager);
+ continue;
+ }
+
/* echo back if flag is set */
if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive)
puts(line);