diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-05 14:16:19 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-05 14:16:19 -0700 |
commit | 8bd3e70d923fc2001d7f8aa5027e7abbcef58ee8 (patch) | |
tree | c1c37dc82237854bbeff7703acc206487e09936d | |
parent | afbb72dfca9489f0e9b56171d9c9df6baa015798 (diff) | |
download | consfigurator-8bd3e70d923fc2001d7f8aa5027e7abbcef58ee8.tar.gz |
rework FILE:HAS-CONTENT and add FILE:HAS-CONTENT-LINES
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | doc/introduction.rst | 8 | ||||
-rw-r--r-- | indentation.el | 4 | ||||
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property/file.lisp | 6 |
4 files changed, 17 insertions, 2 deletions
diff --git a/doc/introduction.rst b/doc/introduction.rst index e62f6b6..7450355 100644 --- a/doc/introduction.rst +++ b/doc/introduction.rst @@ -40,10 +40,16 @@ Try it out / quick start (try-register-data-source :pgp :location #P"/path/to/com.example.consfig.gpg") + (defparameter my-substitution "substititions") + (defhost athena.example.com (:deploy (:ssh (:sudo :as "spwhitton@athena.example.com") :debian-sbcl)) "Web and file server." - (file:has-content "/etc/foo" '("these" "are" "my" "lines")) + (file:has-content "/etc/foo" + #?{Here is my file content. + You can use ${my-substitution} thanks to CL-INTERPOL. + And it's multiline.}) + (file:has-content-lines "/etc/bar" '("these" "are" "my" "lines")) (file:contains-lines "/etc/some.conf" '("FOO=bar"))) Here, "spwhitton" is my username on athena; we have to tell Consfigurator diff --git a/indentation.el b/indentation.el index 6b7d1dc..2a7063e 100644 --- a/indentation.el +++ b/indentation.el @@ -1,6 +1,10 @@ ;; if you eval these forms in Emacs you'll get correct indentation in ;; unevaluated property application specifications +;; actual properties +(put 'file:has-content 'common-lisp-indent-function '(2 2)) + +;; actual properties but suffixed with a period (put 'deploys. 'common-lisp-indent-function '(4 4 2)) (put 'deploys-these. 'common-lisp-indent-function '(4 4 2)) (put 'chroot:os-bootstrapped. 'common-lisp-indent-function '(4 4 2)) diff --git a/src/package.lisp b/src/package.lisp index 7e2e632..7091f51 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -182,6 +182,7 @@ (:use #:cl #:consfigurator #:alexandria) (:local-nicknames (#:re #:cl-ppcre)) (:export #:has-content + #:has-content-lines #:contains-lines #:data-uploaded #:host-data-uploaded diff --git a/src/property/file.lisp b/src/property/file.lisp index c398ace..79b57da 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -28,7 +28,11 @@ point in doing that here because WRITEFILE is synchronous." :no-change (writefile file (unlines new-lines) :try-preserve t)))) -(defprop has-content :posix (path lines) +(defprop has-content :posix (path content) + "Ensure there is a file at PATH whose content is the string CONTENT." + (:apply (writefile path content))) + +(defprop has-content-lines :posix (path lines) "Ensure there is a file at PATH whose lines are the elements of LINES." (:apply (writefile path (unlines lines)))) |