]> err.no Git - systemd/commitdiff
systemctl: print the legend regardless of stdout type, add --no-legend
authorMichal Schmidt <mschmidt@redhat.com>
Mon, 26 Sep 2011 22:48:40 +0000 (00:48 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 27 Sep 2011 10:10:27 +0000 (12:10 +0200)
Print the legend (the column headers and the footer with hints) by
default even to non-tty output. People seem to get confused by the
difference when they redirect the output.

Add a parameter to suppress the printing of the legend.

Related-to: https://bugzilla.redhat.com/show_bug.cgi?id=713567
man/systemctl.xml
src/systemctl.c

index 468141c2bde61a677a589fd34f7021e8752a45ca..2ea6fe9fdf0ba3fd38c7be36582983085b666418 100644 (file)
                                 enqueued.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><option>--no-legend</option></term>
+
+                               <listitem><para>Do not print a legend, i.e.
+                                the column headers and the footer with hints.
+                               </para></listitem>
+                       </varlistentry>
+
                         <varlistentry>
                                 <term><option>--no-pager</option></term>
 
index 2bf2b697e2f91702f6000ac87dfd7587663fc88f..7c2b341852109151204915f5c9ae7c0678573088 100644 (file)
@@ -66,6 +66,7 @@ static const char *arg_job_mode = "replace";
 static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
 static bool arg_immediate = false;
 static bool arg_no_block = false;
+static bool arg_no_legend = false;
 static bool arg_no_pager = false;
 static bool arg_no_wtmp = false;
 static bool arg_no_sync = false;
@@ -331,7 +332,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                         job_len = MAX(job_len, strlen(u->job_type));
         }
 
-        if (on_tty()) {
+        if (!arg_no_legend) {
                 printf("%-25s %-6s %-*s %-*s %-*s", "UNIT", "LOAD",
                        active_len, "ACTIVE", sub_len, "SUB", job_len, "JOB");
                 if (columns() >= 80+12 || arg_full || !arg_no_pager)
@@ -396,7 +397,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                 fputs("\n", stdout);
         }
 
-        if (on_tty()) {
+        if (!arg_no_legend) {
                 printf("\nLOAD   = Reflects whether the unit definition was properly loaded.\n"
                        "ACTIVE = The high-level unit activation state, i.e. generalization of SUB.\n"
                        "SUB    = The low-level unit activation state, values depend on unit type.\n"
@@ -3924,6 +3925,7 @@ static int systemctl_help(void) {
                "     --no-wall        Don't send wall message before halt/power-off/reboot\n"
                "     --no-reload      When enabling/disabling unit files, don't reload daemon\n"
                "                      configuration\n"
+               "     --no-legend      Do not print a legend (column headers and hints)\n"
                "     --no-pager       Do not pipe output into a pager\n"
                "     --no-ask-password\n"
                "                      Do not ask for system passwords\n"
@@ -4074,6 +4076,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 ARG_SYSTEM,
                 ARG_GLOBAL,
                 ARG_NO_BLOCK,
+                ARG_NO_LEGEND,
                 ARG_NO_PAGER,
                 ARG_NO_WALL,
                 ARG_ORDER,
@@ -4102,6 +4105,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 { "system",    no_argument,       NULL, ARG_SYSTEM    },
                 { "global",    no_argument,       NULL, ARG_GLOBAL    },
                 { "no-block",  no_argument,       NULL, ARG_NO_BLOCK  },
+                { "no-legend", no_argument,       NULL, ARG_NO_LEGEND },
                 { "no-pager",  no_argument,       NULL, ARG_NO_PAGER  },
                 { "no-wall",   no_argument,       NULL, ARG_NO_WALL   },
                 { "quiet",     no_argument,       NULL, 'q'           },
@@ -4190,6 +4194,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         arg_no_block = true;
                         break;
 
+                case ARG_NO_LEGEND:
+                        arg_no_legend = true;
+                        break;
+
                 case ARG_NO_PAGER:
                         arg_no_pager = true;
                         break;