Skip to content

Commit

Permalink
Add a function to dump yaml to file
Browse files Browse the repository at this point in the history
  • Loading branch information
charJe committed Apr 22, 2021
1 parent c97ee75 commit 4f256b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
#:convert-node #:convert-scalar #:convert-sequence #:convert-mapping
#:convert-sequence-to-list #:convert-mapping-to-hashtable
;; for serialization
#:stringify))
#:stringify #:dump-file))
8 changes: 8 additions & 0 deletions stringify.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ This relies on the parser parsing yaml null as :null instead of nil."
:else
:collect (format nil "~a: ~a"
key (stringify value)))))))

;;; dump to file
(defun dump-file (yaml path &key if-exists (if-does-not-exist :create))
(with-open-file (out path
:direction :output
:if-exists if-exists
:if-does-not-exist if-does-not-exist)
(write-sequence (stringify yaml) out)))

0 comments on commit 4f256b1

Please sign in to comment.