diff options
author | Tom Willemse | 2013-05-12 22:14:12 +0200 |
---|---|---|
committer | Tom Willemse | 2013-05-12 22:14:12 +0200 |
commit | d61e3814a5791ab75201c1c00b3e7bf76c3dbd83 (patch) | |
tree | e8f92baf099e5de94164f1a651b0fd166425906e | |
parent | 44274838c5b86daf48dcb86a0552084ab6c81508 (diff) | |
download | gitto-d61e3814a5791ab75201c1c00b3e7bf76c3dbd83.tar.gz gitto-d61e3814a5791ab75201c1c00b3e7bf76c3dbd83.zip |
Add write-config
This procedure writes a configuration alist to a format understood by
git.
-rw-r--r-- | gitto/config.scm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gitto/config.scm b/gitto/config.scm index 1ba199e..14151f6 100644 --- a/gitto/config.scm +++ b/gitto/config.scm @@ -19,7 +19,7 @@ (define-module (gitto config) #:use-module (ice-9 rdelim) - #:export (read-config)) + #:export (read-config write-config)) (define (parse-setting line) (let ((idx (string-index line #\=))) @@ -45,3 +45,16 @@ (parse-setting line)))))) (close-port port) config)) + +(define* (write-config config #:optional (file #f)) + (let ((thunk (lambda () (for-each write-section config)))) + (if file + (with-output-to-file file thunk) + (thunk)))) + +(define (write-section section) + (format #t "[~a]~%" (car section)) + (for-each write-setting (cdr section))) + +(define (write-setting setting) + (format #t "~8t~a = ~a~%" (car setting) (cdr setting))) |