Re: Friendly help for psql

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Friendly help for psql
Дата
Msg-id 200804041749.m34HnER08345@momjian.us
обсуждение исходный текст
Ответ на Friendly help for psql  (Greg Sabino Mullane <greg@turnstep.com>)
Список pgsql-patches
Greg Sabino Mullane wrote:
-- Start of PGP signed section.
> Why not run help when someone enters "help" (or "HELP ME!") on the
> command line? \? is hardly an easy thing to remember (and some people
> can't be bothered to actually read the screen...)
>

I have applied this patch (attached) with a few modifications.  First
you were printing \? help for any string beginning with "help" so
"helplkjasdf" also printed help --- I don't think we want that.  I
allowed "help", "help "*, and "help;", so "help select" does work
(prints \?).

I also added \? to the list of \? help options because now someone can
get to \? without typing \?.

Shame we can't make \h more prominent in \? output.  I am going to try
to trim down that top help section, but that will a separate patch
posting by me.

Any adjustments?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/help.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/help.c,v
retrieving revision 1.124
diff -c -c -r1.124 help.c
*** src/bin/psql/help.c    29 Mar 2008 19:40:12 -0000    1.124
--- src/bin/psql/help.c    4 Apr 2008 17:39:05 -0000
***************
*** 188,193 ****
--- 188,194 ----
              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"));
Index: src/bin/psql/mainloop.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/mainloop.c,v
retrieving revision 1.87
diff -c -c -r1.87 mainloop.c
*** src/bin/psql/mainloop.c    1 Jan 2008 19:45:56 -0000    1.87
--- src/bin/psql/mainloop.c    4 Apr 2008 17:39:05 -0000
***************
*** 11,16 ****
--- 11,17 ----

  #include "command.h"
  #include "common.h"
+ #include "help.h"
  #include "input.h"
  #include "settings.h"

***************
*** 171,176 ****
--- 172,187 ----
              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);

В списке pgsql-patches по дате отправления:

Предыдущее
От: "Ceschia, Marcello"
Дата:
Сообщение: Re: Re: [BUGS] BUG #4070: Join more then ~15 tables let postgreSQL produces wrong data
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Friendly help for psql