From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: [herd] Have status display services as a bulleted list. Date: Wed, 23 Nov 2016 15:03:49 -0600 Message-ID: <87oa15j4cq.fsf@dustycloud.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9ehv-00080v-K8 for guix-devel@gnu.org; Wed, 23 Nov 2016 16:03:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9ehs-0007cf-EX for guix-devel@gnu.org; Wed, 23 Nov 2016 16:03:55 -0500 Received: from dustycloud.org ([50.116.34.160]:42416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9ehs-0007ax-8t for guix-devel@gnu.org; Wed, 23 Nov 2016 16:03:52 -0500 Received: from oolong (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id C88D62672C for ; Wed, 23 Nov 2016 16:03:49 -0500 (EST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --=-=-= Content-Type: text/plain I don't know about you, but I am totally unable to read the "herd status" line as it exists in the current state. I mean, I love sexps, but even I don't like a completely flat and ungreppable list printed to stdout. *** Previous output *** cwebber@oolong:~/devel/shepherd$ sudo herd -s /var/run/shepherd/socket status Started: (file-system-/run/systemd xorg-server file-system-/sys/fs/cgroup/cpuacct file-system-/mnt/debian syslogd term-tty1 root-file-system file-system-/sys/fs/cgroup/blkio avahi-daemon file-system-/sys/fs/cgroup upower-daemon console-font-tty6 console-font-tty3 nscd file-system-/run/user file-system-/sys/fs/cgroup/memory file-system-/dev/pts loopback term-tty2 user-processes term-tty4 postgres file-system-/sys/fs/cgroup/perf_event file-system-/sys/fs/cgroup/cpuset device-mapping-home-luks guix-daemon file-system-/sys/fs/cgroup/elogind file-system-/sys/fs/cgroup/devices file-system-/dev/shm dbus-system console-font-tty5 term-tty6 host-name term-tty3 file-system-/sys/fs/cgroup/hugetlb file-system-/sys/fs/cgroup/cpu file-system-/home networking ntpd console-font-tty4 urandom-seed user-file- systems file-system-/sys/fs/cgroup/freezer file-system-/gnu/store root console-font-tty2 term-tty5 console-font-tty1 udev) Stopped: (ssh-daemon) *** New output *** cwebber@oolong:~/devel/shepherd$ sudo ./herd -s /var/run/shepherd/socket status Started: + file-system-/run/systemd + xorg-server + file-system-/sys/fs/cgroup/cpuacct + file-system-/mnt/debian + syslogd + term-tty1 + root-file-system + file-system-/sys/fs/cgroup/blkio + avahi-daemon + file-system-/sys/fs/cgroup + upower-daemon + console-font-tty6 + console-font-tty3 + nscd + file-system-/run/user + file-system-/sys/fs/cgroup/memory + file-system-/dev/pts + loopback + term-tty2 + user-processes + term-tty4 + postgres + file-system-/sys/fs/cgroup/perf_event + file-system-/sys/fs/cgroup/cpuset + device-mapping-home-luks + guix-daemon + file-system-/sys/fs/cgroup/elogind + file-system-/sys/fs/cgroup/devices + file-system-/dev/shm + dbus-system + console-font-tty5 + term-tty6 + host-name + term-tty3 + file-system-/sys/fs/cgroup/hugetlb + file-system-/sys/fs/cgroup/cpu + file-system-/home + networking + ntpd + console-font-tty4 + urandom-seed + user-file-systems + file-system-/sys/fs/cgroup/freezer + file-system-/gnu/store + root + console-font-tty2 + term-tty5 + console-font-tty1 + udev Stopped: - ssh-daemon Whew! I can read that finally. And grep it too! Speaking of grepping, the new bulleted behavior uses a "+" for services enabled, and a "-" for disabled services. That way if you do a grep, you'll still know whether it was enabled/disabled. - Chris --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-herd-Have-status-display-services-as-a-bulleted-list.patch >From d9391382286b1dc5a0719c9e1e6ac1e5941bbb87 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Wed, 23 Nov 2016 14:53:18 -0600 Subject: [PATCH] herd: Have status display services as a bulleted list. * modules/shepherd/scripts/herd.scm (display-status-summary): Display services as an ascii bulleted list. --- modules/shepherd/scripts/herd.scm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/shepherd/scripts/herd.scm b/modules/shepherd/scripts/herd.scm index 0ad52b2..06256c1 100644 --- a/modules/shepherd/scripts/herd.scm +++ b/modules/shepherd/scripts/herd.scm @@ -46,6 +46,11 @@ of pairs." (define (display-status-summary services) "Display a summary of the status of all of SERVICES." + (define (display-services header bullet services) + (display header) + (for-each (lambda (service) + (format #t " ~a ~a~%" bullet (service-canonical-name service))) + services)) (call-with-values (lambda () (partition (match-lambda @@ -53,10 +58,10 @@ of pairs." (car (assoc-ref properties 'running)))) services)) (lambda (started stopped) - (format #t (l10n "Started: ~a~%") - (map service-canonical-name started)) - (format #t (l10n "Stopped: ~a~%") - (map service-canonical-name stopped))))) + (display-services (l10n "Started:\n") "+" + started) + (display-services (l10n "Stopped:\n") "-" + stopped)))) (define (display-detailed-status services) "Display the detailed status of SERVICES." -- 2.10.2 --=-=-=--