Coverage report: /home/ellis/comp/core/app/skel/cli.lisp
Kind | Covered | All | % |
expression | 0 | 286 | 0.0 |
branch | 0 | 18 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; cli.lisp --- Skel CLI Definitions
3
;; CLI implementation of Skel
8
;; *SKEL-CLI* exposes access to the SKEL system from the CLI.
10
(let ((file (when *args* (pop *args*)))
11
(name (when (> *argc* 1) (pop *args*))))
12
;; TODO: test, may need to be sequential for side-effect of pop
16
(std:println (format nil "file already exists: ~A"
17
(or file *default-skelfile*)))
18
(let ((f2 (read-line)))
22
(init-skelfile file name))))
24
(defcmd skc-describe ()
27
(find-skelfile (pathname (car *args*)) :load t)
28
(or *skel-project* *skel-user-config* *skel-system-config*))))
30
(defcmd skc-inspect ()
31
(sb-ext:enable-debugger)
33
(inspect (or *skel-project* *skel-user-config*)))
35
(defun call-with-args (action args)
36
(let* ((*default-pathname-defaults* skel-path))
38
(sk-call *skel-project* action)
40
(sk-call *skel-project* (keywordicate (symbol-name action) '- (string-upcase x))))
43
(defcmd skc-compile ()
44
(call-with-args :compile *args*))
46
(call-with-args :build *args*))
48
(call-with-args :update *args*))
50
(call-with-args :dist *args*))
51
(defcmd skc-install ()
52
(call-with-args :install *args*))
54
(call-with-args :pack *args*))
56
(call-with-args :unpack *args*))
58
(call-with-args :bundle *args*))
59
(defcmd skc-unbundle ()
60
(call-with-args :unbundle *args*))
62
(call-with-args :clean *args*))
64
(call-with-args :test *args*))
66
(call-with-args :bench *args*))
68
(call-with-args :save *args*))
73
(let ((y (string-left-trim ":" x)))
74
(if (sk-project-slot y nil)
75
(skel/core/print::sk-print-slot
77
(sb-mop:class-slots (class-of *skel-project*))
79
:key (lambda (x) (string-downcase (sb-mop:slot-definition-name x))))
82
(log:fatal! "unknown argument: ~A~%" x))))
85
((boundp '*skel-project*)
86
(sk-print *skel-project* :exclude (if ast:*keep-ast* '(:ast :rules) '(:rules))))
87
((boundp '*skel-user-config*) (sk-print *skel-user-config*))
88
((boundp '*skel-system-config*) (sk-print *skel-system-config*))
89
(t (skel-simple-error "skel not installed")))))
94
(string-case ((subseq (pop *args*) 0 3))
95
("pro" (list-all-projects))
96
("log" (apply 'sk-log-list *args*)))))
99
(println (octet-vector-to-hex-string (integer-to-octets (id:id *skel-project*)))))
101
(defopt skc-config (load-user-skelrc (or *arg* user-skelrc) nil))
104
(let ((file (or (when *args* (pop *args*)) (path *skel-project*))))
105
(cli/ed:run-emacsclient (namestring file))))
108
(let ((sk *skel-project*))
109
(sb-ext:enable-debugger)
111
(loop for a in *args*
113
(if-let ((rule (sk-find a sk)))
115
;; TODO 2024-08-23: restart condition here
116
(skel-simple-error "rule not found: ~A" a))))
117
(sk-make sk (aref (sk-rules sk) 0)))))
119
(defcmd skc-status ()
120
(vc:vc-status (sk-vc *skel-project*)))
123
(sb-ext:enable-debugger)
125
(mapc (lambda (script)
126
;; first check if a script with the same name exists, else check
127
;; for a rule definition
128
(if-let ((script (sk-find
129
(pathname-name script)
130
*skel-user-config*)))
132
(call-with-args :run (list script))))
134
(required-argument 'name)))
140
(defcmd skc-search ()
141
"Search the current project and return a date-frame of results."
143
(println (sk-search-project a))))
146
(trace! "starting skel shell")
149
(in-package :sk-user)
150
(use-package :cl-user)
151
(use-package :sb-ext)
152
(use-package :std-user)
153
(println "Welcome to SKEL")
154
(cli/linedit:install-repl :wrap-current t :history "/tmp/skel.history" :killring "/tmp/skel.killring")
155
(sb-impl::toplevel-repl nil)))
157
(defcmd skc-shell () (sk-shell))
159
(define-cli *skel-cli*
161
:version (format nil "0.1.1:~A" (read-line (sb-ext:process-output (vc:run-hg-command "id" '("-i") :stream))))
162
:description "The hackable devtool."
167
:description "print version"
170
(:name "ast" :description "save the intermediate skel AST"
171
:thunk keep-ast-opt :kind boolean)
172
(:name "level" :description "set log level (warn,info,debug,trace)"
174
(:name "config" :description "set a custom skel user config"
179
:description "initialize a skelfile in the current directory"
180
:opts ((:name "name" :description "project name" :kind string))
183
:description "print the current project id"
186
:description "inspect the project skelfile"
187
:opts ((:name "file" :description "path to skelfile" :kind file))
190
:description "make a new skel project"
191
:opts ((:name "name" :description "project name" :kind string))
194
:description "describe a skelfile"
197
:description "edit a project file in emacs."
200
:description "show skel objects slots"
201
:opts ((:name "file" :description "path to skelfile" :kind file))
204
:description "show the current project status"
207
:description "list skel objects"
210
:description "build project targets"
213
:description "search the current project"
216
:description "run a script or command"
219
:description "compile source code"
222
:description "build programs and libraries"
225
:description "update components"
228
:description "save a file"
231
:description "distribute build artifacts"
234
:description "install stuff"
237
:description "pack stuff"
240
:description "unpack stuff"
243
:description "bundle source code"
246
:description "unbundle source code"
249
:description "clean up the project"
252
:description "run tests"
255
:description "run benchmark"
258
:description "open the sk-shell interpreter"