chiark / gitweb /
coredumpctl: add --no-legend option
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Oct 2012 08:45:19 +0000 (09:45 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Oct 2012 10:26:49 +0000 (11:26 +0100)
Useful for completion generation.

man/systemd-coredumpctl.xml
src/journal/coredumpctl.c

index bbb4214..b80aac8 100644 (file)
                                 pager.</para></listitem>
                         </varlistentry>
 
                                 pager.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><option>--no-legend</option></term>
+
+                                <listitem><para>Do not print the column headers.
+                                </para></listitem>
+                        </varlistentry>
+
                 </variablelist>
 
                 <para>The following commands are understood:</para>
                 </variablelist>
 
                 <para>The following commands are understood:</para>
index 03f063f..e1b5a19 100644 (file)
@@ -45,6 +45,7 @@ static Set *matches = NULL;
 static FILE* output = NULL;
 
 static int arg_no_pager = false;
 static FILE* output = NULL;
 
 static int arg_no_pager = false;
+static int arg_no_legend = false;
 
 static Set *new_matches(void) {
         Set *set;
 
 static Set *new_matches(void) {
         Set *set;
@@ -138,6 +139,7 @@ static int parse_argv(int argc, char *argv[]) {
         enum {
                 ARG_VERSION = 0x100,
                 ARG_NO_PAGER,
         enum {
                 ARG_VERSION = 0x100,
                 ARG_NO_PAGER,
+                ARG_NO_LEGEND,
         };
 
         int r, c;
         };
 
         int r, c;
@@ -146,6 +148,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "help",         no_argument,       NULL, 'h'           },
                 { "version" ,     no_argument,       NULL, ARG_VERSION   },
                 { "no-pager",     no_argument,       NULL, ARG_NO_PAGER  },
                 { "help",         no_argument,       NULL, 'h'           },
                 { "version" ,     no_argument,       NULL, ARG_VERSION   },
                 { "no-pager",     no_argument,       NULL, ARG_NO_PAGER  },
+                { "no-legend",    no_argument,       NULL, ARG_NO_LEGEND },
                 { "output",       required_argument, NULL, 'o'           },
                 { NULL,           0,                 NULL, 0             }
         };
                 { "output",       required_argument, NULL, 'o'           },
                 { NULL,           0,                 NULL, 0             }
         };
@@ -171,6 +174,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_no_pager = true;
                         break;
 
                         arg_no_pager = true;
                         break;
 
+                case ARG_NO_LEGEND:
+                        arg_no_legend = true;
+                        break;
+
                 case 'o':
                         if (output) {
                                 log_error("cannot set output more than once");
                 case 'o':
                         if (output) {
                                 log_error("cannot set output more than once");
@@ -242,7 +249,7 @@ static int retrieve(const void *data,
         return 0;
 }
 
         return 0;
 }
 
-static int print_entry(FILE* file, sd_journal *j, int had_header) {
+static int print_entry(FILE* file, sd_journal *j, int had_legend) {
         const char _cleanup_free_
                 *pid = NULL, *uid = NULL, *gid = NULL,
                 *sgnl = NULL, *exe = NULL;
         const char _cleanup_free_
                 *pid = NULL, *uid = NULL, *gid = NULL,
                 *sgnl = NULL, *exe = NULL;
@@ -278,7 +285,7 @@ static int print_entry(FILE* file, sd_journal *j, int had_header) {
 
         format_timestamp(buf, sizeof(buf), t);
 
 
         format_timestamp(buf, sizeof(buf), t);
 
-        if (!had_header)
+        if (!had_legend && !arg_no_legend)
                 fprintf(file, "%-*s %*s %*s %*s %*s %s\n",
                         FORMAT_TIMESTAMP_MAX-1, "TIME",
                         6, "PID",
                 fprintf(file, "%-*s %*s %*s %*s %*s %s\n",
                         FORMAT_TIMESTAMP_MAX-1, "TIME",
                         6, "PID",