[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 02/02: herd: Have status display services as a bulleted list.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 02/02: herd: Have status display services as a bulleted list. |
Date: |
Fri, 25 Nov 2016 23:08:28 +0000 (UTC) |
civodul pushed a commit to branch master
in repository shepherd.
commit 85726ae2ceb276e68716f7f853306279fc62b466
Author: Christopher Allan Webber <address@hidden>
Date: Wed Nov 23 14:53:18 2016 -0600
herd: Have status display services as a bulleted list.
* modules/shepherd/scripts/herd.scm (display-status-summary)
[display-services]: New procedure.
Display services as an ASCII bulleted list.
* tests/basic.sh: Adjust accordingly.
Co-authored-by: Ludovic Courtès <address@hidden>
---
modules/shepherd/scripts/herd.scm | 15 +++++++++++----
tests/basic.sh | 7 ++++---
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/modules/shepherd/scripts/herd.scm
b/modules/shepherd/scripts/herd.scm
index 0ad52b2..ebcd1e1 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -46,6 +46,13 @@ of pairs."
(define (display-status-summary services)
"Display a summary of the status of all of SERVICES."
+ (define (display-services header bullet services)
+ (unless (null? 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 +60,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."
diff --git a/tests/basic.sh b/tests/basic.sh
index e80d2f5..d9cc67e 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -138,7 +138,7 @@ then false; else true; fi
# Unload two services, make sure the other it still around.
$herd unload root broken
$herd unload root test
-$herd status | grep "Stopped: (test-2)"
+$herd status | grep -e "- test-2"
$herd reload root "$conf"
test "`$herd status`" == "$pristine_status"
@@ -199,8 +199,9 @@ then false; else true; fi
# Unload everything and make sure only 'root' is left.
$herd unload root all
-$herd status | grep "Stopped: ()"
-$herd status | grep "Started: (root)"
+if $herd status | grep "Stopped:"
+then false; else true; fi
+$herd status | grep -e "+ root"
$herd stop root
! kill -0 $shepherd_pid