Skip to content

Commit cbe1db0

Browse files
committed
feat: clean all
1 parent 05fe1f8 commit cbe1db0

File tree

12 files changed

+107
-23
lines changed

12 files changed

+107
-23
lines changed

cmds/clean/all.lisp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;;;; cmds/clean/all.lisp --- Do all cleaning tasks
2+
3+
;;; Commentary
4+
;;
5+
;; The `clean all' command definition.
6+
;;
7+
8+
;;; Code
9+
10+
(defpackage qob-cli/clean/all
11+
(:use cl)
12+
(:export command))
13+
14+
(in-package :qob-cli/clean/all)
15+
16+
(defun options ()
17+
"Options for `clean all' command."
18+
(list ))
19+
20+
(defun handler (cmd)
21+
"Handler for `clean all' command."
22+
(qob-cli:call-script "clean/all" cmd))
23+
24+
(defun command ()
25+
"The `clean all' command."
26+
(clingon:make-command
27+
:name "all"
28+
:description "Do all cleaning tasks"
29+
:options (options)
30+
:handler #'handler))
31+
32+
;;; End of cmds/clean/all.lisp

cmds/clean/dist.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
(defun handler (cmd)
2121
"Handler for `clean dist' command."
22-
(let ((qob-cli:inhibit-ql-download t))
22+
(let ((qob-cli:inhibit-ql-download-p t))
2323
(qob-cli:call-script "clean/dist" cmd)))
2424

2525
(defun command ()

cmds/clean/workspace.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
(defun handler (cmd)
2121
"Handler for `clean workspace' command."
22-
(let ((qob-cli:inhibit-ql-download t))
22+
(let ((qob-cli:inhibit-ql-download-p t))
2323
(qob-cli:call-script "clean/workspace" cmd)))
2424

2525
(defun command ()

cmds/core/clean.lisp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
:usage "<type>"
3030
:options (options)
3131
:handler #'handler
32-
:sub-commands `(,(qob-cli/clean/dist:command)
32+
:sub-commands `(,(qob-cli/clean/all:command)
33+
,(qob-cli/clean/dist:command)
3334
,(qob-cli/clean/workspace:command))))
3435

3536
;;; End of cmds/core/clean.lisp

lisp/_prepare.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ Argument ENV-NAME is used to get the argument string."
196196
(defvar qob-quicklisp-installed-p (uiop:getenv "QOB_QUICKLISP_INSTALLED")
197197
"Return non-nil if Quicklisp is already installed.")
198198

199+
(defvar qob-inhibit-ql-download-p (uiop:getenv "QOB_INHIBIT_QL_DOWNLOAD")
200+
"Return non-nil if Quicklisp is inhibit to be downloaded.")
201+
199202
(defun qob-dot-impls ()
200203
"Return the directory path to `.qob/type/version'.
201204

lisp/clean/all.lisp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
;;;; lisp/clean/all.lisp --- Do all cleaning tasks
2+
3+
;;; Commentary
4+
;;
5+
;; Command use to do all cleaning tasks
6+
;;
7+
;; $ qob clean all
8+
;;
9+
10+
;;; Code
11+
12+
(defconstant qob-clean-all--tasks-total 2
13+
"Count cleaning task.")
14+
15+
(defvar qob-clean-all--tasks-count 0
16+
"Count cleaning task.")
17+
18+
(defvar qob-clean-all--tasks-cleaned 0
19+
"Total cleaned tasks.")
20+
21+
(defmacro qob--clean-section (title &rest body)
22+
"Print clean up TITLE and execute BODY."
23+
`(let (qob-no-cleaning-operation-p)
24+
(incf qob-clean-all--tasks-count)
25+
(qob-with-progress
26+
(concatenate 'string
27+
(qob-format " - [~A/~a] " qob-clean-all--tasks-count qob-clean-all--tasks-total)
28+
(qob-format "~A... " ,title))
29+
(qob-with-verbosity 'debug ,@body)
30+
(if qob-no-cleaning-operation-p
31+
"skipped ✗"
32+
(progn
33+
(incf qob-clean-all--tasks-cleaned)
34+
"done ✓")))))
35+
36+
(qob-start
37+
(qob-msg "Applying ~A cleaning tasks..." qob-clean-all--tasks-total)
38+
(qob-msg "")
39+
(qob--clean-section (qob-format "Cleaning ~A" (qob-ansi-green "workspace"))
40+
(qob-call "clean/workspace"))
41+
(qob--clean-section (qob-format "Cleaning ~A" (qob-ansi-green "dist"))
42+
(qob-call "clean/dist"))
43+
(qob-msg "")
44+
(qob-info "(Total of ~A task~A cleaned, ~A skipped)"
45+
qob-clean-all--tasks-cleaned
46+
(qob--sinr qob-clean-all--tasks-cleaned "" "s")
47+
(- qob-clean-all--tasks-count qob-clean-all--tasks-cleaned)))
48+
49+
;;; End of lisp/clean/all.lisp

lisp/clean/workspace.lisp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
;;; Code
1111

1212
(qob-start
13-
(qob-with-progress
14-
(qob-format "Deleting ~A... " qob-dot)
15-
(uiop:delete-directory-tree (pathname qob-dot) :validate t)
16-
"done ✓")
17-
18-
(qob-println "")
19-
(qob-info "(Workspace is now cleaned)"))
13+
(let ((deleted))
14+
(qob-with-progress
15+
(qob-format "Deleting ~A... " qob-dot)
16+
(setq deleted (ignore-errors (delete-directory qob-dot :recursive t)))
17+
(if deleted "done ✓" "skipped ✗"))
18+
(qob-println "")
19+
(if deleted
20+
(qob-info "(Workspace is now cleaned)")
21+
(progn
22+
(qob-info "(Failed to clean up workspace)")
23+
(setq qob-no-cleaning-operation-p t)))))
2024

2125
;;; End of lisp/clean/workspace.lisp

qob-cli.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(:file "src/utils")
1313
;; Commands
1414
(:file "cmds/create/cl-project")
15+
(:file "cmds/clean/all")
1516
(:file "cmds/clean/dist")
1617
(:file "cmds/clean/workspace")
1718
(:file "cmds/core/build")

scripts/_prepare.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(defun qob-copy-lisp-dir ()
2020
"Copy `lisp' directory over."
2121
(when (probe-file "bin/lisp/")
22-
(el-lib:el-delete-directory "bin/lisp/"))
22+
(delete-directory "bin/lisp/" :recursive t))
2323
(copy-directory:copy (el-lib:el-expand-fn "lisp/")
2424
(el-lib:el-expand-fn "bin/lisp/")))
2525

src/el-lib.lisp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
el-expand-file-name
1818
el-executable-find
1919
el-move-path
20-
el-delete-directory
2120
el-directory-files
2221
el-file-name-directory))
2322

@@ -69,10 +68,6 @@
6968
"Like `expand-file-name' function; returns a string."
7069
(namestring (el-expand-fn path dir-name)))
7170

72-
(defun el-delete-directory (dir)
73-
"Delete the DIR."
74-
(sb-ext:delete-directory (el-lib:el-expand-fn dir) :recursive t))
75-
7671
(defun el-directory-files (dir)
7772
"Return a list of names of files in DIR."
7873
(append (uiop:subdirectories dir)

src/packages.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
(:use cl)
1212
(:export
1313
;; src/utils.lsip
14-
inhibit-ql-download
14+
inhibit-ql-download-p
1515
force-global-p
1616
exec-dir
1717
call-script

src/utils.lisp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(in-package :qob-cli)
1111

12-
(defvar inhibit-ql-download nil
12+
(defvar inhibit-ql-download-p nil
1313
"Set to t if you don't want download `quicklisp.lisp' file on start.")
1414

1515
(defvar force-global-p nil
@@ -103,10 +103,9 @@ Argument CMD is used to extract positional arguments and options."
103103
(setf (uiop:getenv "QOB_TEMP_FILE") (el-lib:el-expand-file-name "tmp" (dot-global)))
104104
(setf (uiop:getenv "QOB_LISP_ROOT") (lisp-root))
105105
(setf (uiop:getenv "QOB_USER_INIT") (user-init cmd))
106-
(unless inhibit-ql-download
107-
(if (quicklisp-installed-p cmd)
108-
(setf (uiop:getenv "QOB_QUICKLISP_INSTALLED") "t")
109-
(quicklisp-download cmd))))
106+
(if (quicklisp-installed-p cmd)
107+
(setf (uiop:getenv "QOB_QUICKLISP_INSTALLED") "t")
108+
(quicklisp-download cmd)))
110109

111110
(defun program-name ()
112111
"Lisp program we target to run."
@@ -142,7 +141,7 @@ Argument CMD is used to extract positional arguments and options."
142141
(ql (lisp-script "_ql"))
143142
(script (lisp-script script)))
144143
(call-impls (concatenate 'list
145-
(if (or inhibit-ql-download
144+
(if (or inhibit-ql-download-p
146145
(quicklisp-installed-p cmd))
147146
(list "--load" no-ql)
148147
(list "--load" (quicklisp-lisp cmd)

0 commit comments

Comments
 (0)