chiark / gitweb /
busctl: add --no-legend and use in bash completion
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 19 Feb 2014 16:35:35 +0000 (17:35 +0100)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 19 Feb 2014 16:35:35 +0000 (17:35 +0100)
man/busctl.xml
shell-completion/bash/busctl
src/libsystemd/sd-bus/busctl.c

index 33420a9cbc1f4ee30b9faa9c2d4ef6e958bb967e..f352da1d7b4be7f395cb6ee65e4e648fe466328a 100644 (file)
@@ -93,6 +93,16 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--no-legend</option></term>
+
+        <listitem>
+          <para>Do not print the legend,
+          i.e. the column headers and the
+          footer.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--system</option></term>
 
index 0727241460dce63fefb395cff336c95cdcee1135..06d5d9383d589f4fcf9b9b4f3696363fe718b4a7 100644 (file)
@@ -32,14 +32,14 @@ __get_machines() {
 
 __get_endpoints() {
         local a b
-        busctl list --no-pager | { while read a b; do echo " $a"; done; };
+        busctl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
 }
 
 _busctl() {
         local i verb comps
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local -A OPTS=(
-               [STANDALONE]='-h --help --version --no-pager --system --user
+               [STANDALONE]='-h --help --version --no-pager --no-legend --system --user
                              --show-machine --unique --acquired --activatable'
                       [ARG]='-H --host -M --machine --address --match'
         )
index 1d7f575314b7ec4512a77ddc837c41aa2653993e..a59b8eab4fa9f04ab9b7217ccbaf62dc8efee258 100644 (file)
@@ -34,6 +34,7 @@
 #include "bus-dump.h"
 
 static bool arg_no_pager = false;
+static bool arg_legend = true;
 static char *arg_address = NULL;
 static bool arg_unique = false;
 static bool arg_acquired = false;
@@ -106,13 +107,15 @@ static int list_bus_names(sd_bus *bus, char **argv) {
         merged[n] = NULL;
         strv_sort(merged);
 
-        printf("%-*s %*s %-*s %-*s %-*s %-*s %-*s %-*s",
-               (int) max_i, "NAME", 10, "PID", 15, "PROCESS", 16, "USER", 13, "CONNECTION", 25, "UNIT", 10, "SESSION", 19, "CONNECTION-NAME");
+        if (arg_legend) {
+                printf("%-*s %*s %-*s %-*s %-*s %-*s %-*s %-*s",
+                       (int) max_i, "NAME", 10, "PID", 15, "PROCESS", 16, "USER", 13, "CONNECTION", 25, "UNIT", 10, "SESSION", 19, "CONNECTION-NAME");
 
-        if (arg_show_machine)
-                puts(" MACHINE");
-        else
-                putchar('\n');
+                if (arg_show_machine)
+                        puts(" MACHINE");
+                else
+                        putchar('\n');
+        }
 
         STRV_FOREACH(i, merged) {
                 _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
@@ -323,6 +326,7 @@ static int help(void) {
                "  -h --help               Show this help\n"
                "     --version            Show package version\n"
                "     --no-pager           Do not pipe output into a pager\n"
+               "     --no-legend          Do not show the headers and footers\n"
                "     --system             Connect to system bus\n"
                "     --user               Connect to user bus\n"
                "  -H --host=[USER@]HOST   Operate on remote host\n"
@@ -348,6 +352,7 @@ static int parse_argv(int argc, char *argv[]) {
         enum {
                 ARG_VERSION = 0x100,
                 ARG_NO_PAGER,
+                ARG_NO_LEGEND,
                 ARG_SYSTEM,
                 ARG_USER,
                 ARG_ADDRESS,
@@ -362,6 +367,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     },
+                { "no-legend",    no_argument,       NULL, ARG_NO_LEGEND    },
                 { "system",       no_argument,       NULL, ARG_SYSTEM       },
                 { "user",         no_argument,       NULL, ARG_USER         },
                 { "address",      required_argument, NULL, ARG_ADDRESS      },
@@ -396,6 +402,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_no_pager = true;
                         break;
 
+                case ARG_NO_LEGEND:
+                        arg_legend = false;
+                        break;
+
                 case ARG_USER:
                         arg_user = true;
                         break;