Coverage report: /home/ellis/comp/core/lib/cli/tools/sys.lisp
Kind | Covered | All | % |
expression | 0 | 65 | 0.0 |
branch | 0 | 2 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; sys.lisp --- System CLI Tools
6
(in-package :cli/tools/sys)
8
(deferror systemd-error (simple-error error) ())
10
(defun systemd-error (fmt &rest args)
11
(error 'systemd-error :format-arguments args :format-control fmt))
13
(defparameter *systemctl* (find-exe "systemctl"))
15
(defun run-systemctl (args &key (output t))
16
(let ((proc (sb-ext:run-program *systemctl* (or args nil) :output output)))
17
(unless (or (= 0 #1=(sb-ext:process-exit-code proc))
19
(systemd-error "SYSTEMCTL command failed: ~A ~A" *systemctl* (or args "")))))
21
(defun systemctl-start (&rest args)
22
(run-systemctl `("start" ,@args)))
24
(defun systemctl-stop (&rest args)
25
(run-systemctl `("stop" ,@args)))
27
(defun systemctl-status (unit &key (user t) (lines 20))
29
`("status" ,@(when lines `("--lines" ,(format nil "~A" lines)))
31
,@(when user '("--user"))
34
(defun systemctl-restart (&rest args)
35
(run-systemctl `("restart" ,@args)))
37
(defun systemctl-json (&rest args)
39
(with-output-to-string (s)
40
(run-systemctl (concatenate 'list '("-q" "-o" "json") args) :output s))
43
;; (systemctl-json "--user")