[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 05/05: Asking for the doc of unknown actions raises an error.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 05/05: Asking for the doc of unknown actions raises an error. |
Date: |
Sat, 23 Jan 2016 22:20:27 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit f13542da18c34a967efab262bb9729e64a96395e
Author: Ludovic Courtès <address@hidden>
Date: Sat Jan 23 23:19:09 2016 +0100
Asking for the doc of unknown actions raises an error.
* modules/shepherd/service.scm (doc): Raise &unknown-action-error when
asked for the doc of an unknown action.
* tests/basic.sh: Add test.
---
modules/shepherd/service.scm | 15 +++++++--------
tests/basic.sh | 5 +++++
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 46dc4c7..64d56ef 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -426,14 +426,13 @@ wire."
;; Display documentation of given actions.
(for-each
(lambda (the-action)
- (local-output "~a: ~a"
- the-action
- (let ((action-object
- (lookup-action obj
- (string->symbol the-action))))
- (if action-object
- (action:doc action-object)
- (gettext "This action does not exist.")))))
+ (let ((action-object
+ (lookup-action obj (string->symbol the-action))))
+ (unless action-object
+ (raise (condition (&unknown-action-error
+ (action the-action)
+ (service obj)))))
+ (local-output "~a: ~a" the-action (action:doc action-object))))
(cdr args)))
((list-actions)
(local-output "~a ~a"
diff --git a/tests/basic.sh b/tests/basic.sh
index 14cc22b..462f8ad 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -104,6 +104,11 @@ then false; else true; fi
if $herd status dmd foo bar baz;
then false; else true; fi
+# Asking for the doc of specific actions.
+$herd doc dmd action status
+if $herd doc dmd action an-action-that-does-not-exist
+then false; else true; fi
+
# Loading nonexistent file.
if $herd load dmd /does/not/exist.scm;
then false; else true; fi