Reorganize format options of psql in alphabetical order
authorMichael Paquier <[email protected]>
Tue, 6 Nov 2018 06:04:40 +0000 (15:04 +0900)
committerMichael Paquier <[email protected]>
Tue, 6 Nov 2018 06:04:40 +0000 (15:04 +0900)
This makes the addition of new formats easier, and documentation lookups
easier.

Author: Daniel Vérité
Reviewed-by: Fabien Coelho
Discussion: https://postgr.es/m/alpine.DEB.2.20.1803081004241.2916@lancre

doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/command.c
src/bin/psql/tab-complete.c
src/include/fe_utils/print.h

index eb9d93a168e43dee67c1fcc8b64cee96f99ddf77..a1ca94057bdc22464b37606e35c2133b9f77e4f8 100644 (file)
@@ -2584,12 +2584,11 @@ lo_import 152801
           <term><literal>format</literal></term>
           <listitem>
           <para>
-          Sets the output format to one of <literal>unaligned</literal>,
-          <literal>aligned</literal>, <literal>wrapped</literal>,
-          <literal>html</literal>, <literal>asciidoc</literal>,
+          Sets the output format to one of <literal>aligned</literal>,
+          <literal>asciidoc</literal>, <literal>html</literal>,
           <literal>latex</literal> (uses <literal>tabular</literal>),
-          <literal>latex-longtable</literal>, or
-          <literal>troff-ms</literal>.
+          <literal>latex-longtable</literal>, <literal>troff-ms</literal>,
+          <literal>unaligned</literal>, or <literal>wrapped</literal>.
           Unique abbreviations are allowed.  (That would mean one letter
           is enough.)
           </para>
@@ -2615,10 +2614,10 @@ lo_import 152801
           </para>
 
           <para>
-          The <literal>html</literal>, <literal>asciidoc</literal>, <literal>latex</literal>,
-          <literal>latex-longtable</literal>, and <literal>troff-ms</literal>
-          formats put out tables that are intended to
-          be included in documents using the respective mark-up
+          The <literal>asciidoc</literal>, <literal>html</literal>,
+          <literal>latex</literal>, <literal>latex-longtable</literal>, and
+          <literal>troff-ms</literal> formats put out tables that are intended
+          to be included in documents using the respective mark-up
           language. They are not complete documents! This might not be
           necessary in <acronym>HTML</acronym>, but in
           <application>LaTeX</application> you must have a complete
index 5b4d54a442599dc54291c80ab8a5bc09d884ad9b..0dea54d3ce07e166bd9df2aaa2848a06747fd9cb 100644 (file)
@@ -3560,21 +3560,15 @@ _align2string(enum printFormat in)
        case PRINT_NOTHING:
            return "nothing";
            break;
-       case PRINT_UNALIGNED:
-           return "unaligned";
-           break;
        case PRINT_ALIGNED:
            return "aligned";
            break;
-       case PRINT_WRAPPED:
-           return "wrapped";
+       case PRINT_ASCIIDOC:
+           return "asciidoc";
            break;
        case PRINT_HTML:
            return "html";
            break;
-       case PRINT_ASCIIDOC:
-           return "asciidoc";
-           break;
        case PRINT_LATEX:
            return "latex";
            break;
@@ -3584,6 +3578,12 @@ _align2string(enum printFormat in)
        case PRINT_TROFF_MS:
            return "troff-ms";
            break;
+       case PRINT_UNALIGNED:
+           return "unaligned";
+           break;
+       case PRINT_WRAPPED:
+           return "wrapped";
+           break;
    }
    return "unknown";
 }
@@ -3639,25 +3639,25 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
    {
        if (!value)
            ;
-       else if (pg_strncasecmp("unaligned", value, vallen) == 0)
-           popt->topt.format = PRINT_UNALIGNED;
        else if (pg_strncasecmp("aligned", value, vallen) == 0)
            popt->topt.format = PRINT_ALIGNED;
-       else if (pg_strncasecmp("wrapped", value, vallen) == 0)
-           popt->topt.format = PRINT_WRAPPED;
-       else if (pg_strncasecmp("html", value, vallen) == 0)
-           popt->topt.format = PRINT_HTML;
        else if (pg_strncasecmp("asciidoc", value, vallen) == 0)
            popt->topt.format = PRINT_ASCIIDOC;
+       else if (pg_strncasecmp("html", value, vallen) == 0)
+           popt->topt.format = PRINT_HTML;
        else if (pg_strncasecmp("latex", value, vallen) == 0)
            popt->topt.format = PRINT_LATEX;
        else if (pg_strncasecmp("latex-longtable", value, vallen) == 0)
            popt->topt.format = PRINT_LATEX_LONGTABLE;
        else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
            popt->topt.format = PRINT_TROFF_MS;
+       else if (pg_strncasecmp("unaligned", value, vallen) == 0)
+           popt->topt.format = PRINT_UNALIGNED;
+       else if (pg_strncasecmp("wrapped", value, vallen) == 0)
+           popt->topt.format = PRINT_WRAPPED;
        else
        {
-           psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
+           psql_error("\\pset: allowed formats are aligned, asciidoc, html, latex, latex-longtable, troff-ms, unaligned, wrapped\n");
            return false;
        }
    }
index a980f92e11bed62ab8fc79403a9fc75d26cf16ef..7294824948c0eeb772c6dc57d6531a885ed615ba 100644 (file)
@@ -3539,9 +3539,9 @@ psql_completion(const char *text, int start, int end)
    else if (TailMatchesCS("\\pset", MatchAny))
    {
        if (TailMatchesCS("format"))
-           COMPLETE_WITH_CS("unaligned", "aligned", "wrapped", "html",
-                            "asciidoc", "latex", "latex-longtable",
-                            "troff-ms");
+           COMPLETE_WITH_CS("aligned", "asciidoc", "html", "latex",
+                            "latex-longtable", "troff-ms", "unaligned",
+                            "wrapped");
        else if (TailMatchesCS("linestyle"))
            COMPLETE_WITH_CS("ascii", "old-ascii", "unicode");
        else if (TailMatchesCS("pager"))
index 83320d06bdd2cc55e125edc48011e8953e2f78b2..b761349bc72ea6d88b1f337a36a1b1902027b993 100644 (file)
 enum printFormat
 {
    PRINT_NOTHING = 0,          /* to make sure someone initializes this */
-   PRINT_UNALIGNED,
    PRINT_ALIGNED,
-   PRINT_WRAPPED,
-   PRINT_HTML,
    PRINT_ASCIIDOC,
+   PRINT_HTML,
    PRINT_LATEX,
    PRINT_LATEX_LONGTABLE,
-   PRINT_TROFF_MS
+   PRINT_TROFF_MS,
+   PRINT_UNALIGNED,
+   PRINT_WRAPPED
    /* add your favourite output format here ... */
 };