-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmowedline-client.scm
62 lines (52 loc) · 2 KB
/
mowedline-client.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;; This file is part of mowedline.
;; Copyright (C) 2011-2013 John J. Foerch
;;
;; mowedline is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; mowedline is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with mowedline. If not, see <http://www.gnu.org/licenses/>.
(import chicken scheme)
(use srfi-1
extras
(prefix dbus dbus:)
fmt
(prefix imperative-command-line-a icla:))
(include "version")
(include "mowedline-dbus-context")
(icla:help-heading
(sprintf "mowedline-client version ~A, by John J. Foerch" version))
(icla:define-command-group client-options
((quit)
doc: "quit the program"
(dbus:call mowedline-dbus-context "quit"))
((read widget)
doc: "updates widget by reading lines from stdin"
(let loop ()
(let ((line (read-line (current-input-port))))
(unless (eof-object? line)
(when (equal? '(#f) (dbus:call mowedline-dbus-context "update" widget line))
(printf "widget not found, ~S~%" widget))
(loop)))))
((update widget value)
doc: "updates widget with value"
(when (equal? '(#f) (dbus:call mowedline-dbus-context "update" widget value))
(printf "widget not found, ~S~%" widget)))
((log symlist)
doc: "enable or disable logging; [+-]SYM1,[+-]SYM2,..."
(dbus:call mowedline-dbus-context "log" symlist)))
(condition-case
(icla:parse (command-line-arguments))
(e (exn icla parse)
(fmt #t "Error: "
(get-condition-property e 'exn 'location) " - "
(get-condition-property e 'exn 'message) " "
(get-condition-property e 'exn 'arguments)
nl)))