diff --git a/package.lisp b/package.lisp index 84d4eee..24359bb 100755 --- a/package.lisp +++ b/package.lisp @@ -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)) diff --git a/stringify.lisp b/stringify.lisp index 2de236a..e885557 100644 --- a/stringify.lisp +++ b/stringify.lisp @@ -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)))