Coverage report: /home/ellis/comp/core/lib/cli/tools/pkg.lisp

KindCoveredAll%
expression056 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; pkg.lisp --- CLI Tools
2
 
3
 ;; Convenience functions for working with common CLI programs
4
 
5
 ;;; Code:
6
 (in-package :cli/int)
7
 
8
 (defparameter *cli-tool-packages* `(,(package-name *package*)))
9
 (setq *defpkg-hook* (lambda (x) (pushnew (package-name x) *cli-tool-packages* :test 'string=)))
10
 
11
 (defpkg :cli/tools/proto
12
   (:use :cl :std :cli/env :config :ast)
13
   (:export :define-cli-tool :*cli-tools* :cli-tool-config
14
    :cli-tool-error))
15
 
16
 (defpkg :cli/tools/term
17
   (:use :cl :std :cli/tools/proto :cli/env :config :toml :ast)
18
   (:export
19
    :*term* :*alacritty-config-path*
20
    :alacritty-config :term-config
21
    :run-term :with-term
22
    :term-error :load-alacritty-config
23
    :*scriptreplay*
24
    :*script*
25
    :run-script :run-scriptreplay
26
    :run-fbterm :*fbterm* :fbterm-error))
27
 
28
 (defpkg :cli/tools/fs
29
   (:use :cl :std :cli/tools/proto :cli/env)
30
   (:export
31
    #:fs-error))
32
 
33
 (defpkg :cli/tools/tmux
34
   (:use :cl :std :cli/tools/proto :cli/env :cli/tools/term)
35
   (:import-from :obj/config
36
    :defconfig :make-config :find-config)
37
   (:export
38
    :*tmux-user-config-path*
39
    :*tmux-system-config-path*
40
    :*default-tmux-socket*
41
    :run-tmux :spawn-tmux
42
    :tmux-format
43
    :tmux-format-string
44
    :*tmux-variables*
45
    :*tmux-var-table*
46
    :simple-tmux-error
47
    :tmux-config))
48
 
49
 (defpkg :cli/tools/cc
50
   (:use :cl :std :cli/tools/proto :cli/env)
51
   (:export
52
    :*cc*
53
    :*ld*
54
    :run-cc
55
    :run-ld
56
    :run-gdb
57
    :gdb-error
58
    :*gdb*
59
    :*lldb*
60
    :lldb-error
61
    :run-lldb
62
    :cc-error
63
    :*nvcc*
64
    :run-nvcc
65
    :nvcc-error))
66
 
67
 (defpkg :cli/tools/build
68
   (:use :cl :std :cli/tools/proto :cli/env)
69
   (:export
70
    :*make*
71
    :run-make
72
    :*cmake*
73
    :run-cmake
74
    :*meson*
75
    :run-meson
76
    :*ninja*
77
    :run-ninja))
78
 
79
 (defpkg :cli/tools/media
80
   (:use :cl :std :cli/tools/proto :cli/env :config :ini :ast)
81
   (:export
82
    :*ffmpeg*
83
    :run-ffmpeg
84
    :ffmpeg-error
85
    :*mpv*
86
    :run-mpv
87
    :mpv-error
88
    :list-ffmpeg-codecs
89
    :list-ffmpeg-formats
90
    :exec-picard
91
    :load-picard-config
92
    :picard-config
93
    :*picard-config-path*
94
    :*picard-commands*
95
    :ffmpeg-format
96
    :ffmpeg-codec
97
    :ffmpeg-codec-props
98
    :ffmpeg-format-props
99
    :do-picard
100
    :picard-error
101
    :wireplumber-error
102
    :mpv-config
103
    :*mpv-config-path*))
104
 
105
 (defpkg :cli/tools/go
106
   (:nicknames :tools/go)
107
   (:use :cl :std :cli/tools/proto :cli/env)
108
   (:export
109
    :*go*
110
    :run-go
111
    :go-install
112
    :go-error))
113
 
114
 (defpkg :cli/tools/plot
115
   (:nicknames :tools/plot)
116
   (:use :cl :std :cli/tools/proto :cli/env)
117
   (:export
118
    :open-gnuplot
119
    :close-gnuplot
120
    :*gnuplot-process*
121
    :gnuplot-send
122
    :with-gnuplot-stream
123
    :with-gnuplot-term
124
    :run-dot :dot-error :*dot*))
125
 
126
 (defpkg :cli/tools/net
127
   (:use :cl :std :cli/tools/proto :cli/env :uri :config :ast :ini)
128
   (:import-from :std/os :with-umask)
129
   (:export
130
    :*browser*
131
    :run-browser
132
    :browse-url
133
    :browser-error
134
    :wg-showconf
135
    :wg-show
136
    :wg-set
137
    :wg-setconf
138
    :wg-generate-key-files
139
    :wg-generate-keys
140
    :wg-public-key
141
    :wg-private-key
142
    :run-wg
143
    :run-easyrsa
144
    :easyrsa-init-pki
145
    :easyrsa-gen-req
146
    :easyrsay-build-ca
147
    :*easy-rsa-directory*
148
    :*easy-rsa-vars-file*
149
    :*wg*
150
    :wg-error
151
    :ip-addr-add
152
    :ip-link-up
153
    :ip-link-add
154
    :run-ip
155
    :simple-ip-error
156
    :*ytdl*
157
    :run-ytdl
158
    :ytdl-error
159
    :ytdl-config
160
    :browser-config
161
    :chromium-config
162
    :firefox-config
163
    :caddy-error
164
    :*caddy*
165
    :run-caddy*
166
    :run-caddy
167
    :start-caddy
168
    :ytdl-list
169
    :ytdl-user-agent
170
    :ytdl-extractors
171
    :ytdl-json
172
    :run-transmission-remote
173
    :run-transmission-daemon
174
    :transmission-remote-error
175
    :*transmission-remote*
176
    :transmission-daemon-error
177
    :*transmission-daemon*))
178
 
179
 (defpkg :cli/tools/pacman
180
   (:use :cl :std :cli/tools/proto :cli/env :config :ast)
181
   (:export :*pacman* :run-pacman :pacman-error
182
    :pacman-upgrade :pacman-config :load-pacman-config :makepkg 
183
    :makepkg-config :load-makepkg-config :makepkg-error))
184
 
185
 (defpkg :cli/tools/mail
186
   (:use :cl :std :cli/tools/proto :cli/env)
187
   (:export :mail-error :*mail-program* :run-notmuch :run-offlineimap :*notmuch* :*offlineimap*
188
            :notmuch-search
189
            :notmuch-address
190
            :notmuch-tag
191
            :notmuch-count
192
            :notmuch-show))
193
 
194
 (defpkg :cli/tools/sys
195
   (:use :cl :std :cli/tools/proto :cli/env)
196
   (:export :*systemctl* :run-systemd :run-systemctl
197
    :systemd-error
198
            :systemctl-stop
199
    :systemctl-start
200
    :systemctl-restart
201
    :systemctl-status
202
    :systemctl-json))
203
 
204
 (defpkg :cli/tools/rust
205
   (:nicknames :tools/rust)
206
   (:use :cl :std :cli/tools/proto :cli/env)
207
   (:export
208
    #:cargo-error
209
    #:*cargo*
210
    #:*rustup*
211
    #:run-cargo
212
    #:rustup-error
213
    #:run-rustup
214
    #:cargo-install
215
    #:cargo-clean))
216
 
217
 (defpkg :cli/tools/sbcl
218
   (:use :cl :std :cli/tools/proto :cli/env)
219
   (:export
220
    :*sbcl*
221
    :run-sbcl
222
    :sbcl-error
223
    :with-sbcl
224
    :*sbcl-runtime-options*
225
    :*sbcl-toplevel-options*))
226
 
227
 (defpkg :cli/tools/virt
228
   (:use :cl :std :cli/tools/proto :cli/env)
229
   (:export :*buildah* :*podman* :*qemu*
230
    :run-buildah :run-podman :run-qemu :podman-machine-upgrade
231
    :start-podman-service :find-qemu-exe :run-qemu-img))
232
 
233
 (setq *defpkg-hook* nil)
234
 
235
 (in-package :cli/tools/proto)
236
 
237
 (defconfig cli-tool-config () ())
238
 
239
 (defvar *cli-tools* nil)
240
 
241
 (define-condition cli-tool-error (simple-error) ())
242
 
243
 (defmacro define-cli-tool (name args &body body)
244
   "Define a new cli tool with a NAME-error condition, a *NAME* variable, and a
245
 run-NAME function.
246
 
247
 ARGS and BODY are parsed as the args and body of the run-NAME function."
248
   (with-gensyms (var err run)
249
     (let ((%name (string name)))
250
       (setf 
251
        var (symbolicate #\* %name #\*)
252
        err (symbolicate %name "-ERROR")
253
        run (symbolicate "RUN-" %name))
254
       `(eval-always
255
          (defvar ,var 
256
            (find-exe ,(etypecase name
257
                         (string name)
258
                         (symbol (string-downcase %name)))))
259
          ,@(when var `((pushnew ,name *cli-tools*)))
260
          (deferror ,err (cli-tool-error) () (:auto t))
261
          (defun ,run ,args ,@body)))))