summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-07-10 02:36:37 +0000
committerrsiddharth <s@ricketyspace.net>2016-07-10 02:36:37 +0000
commit5a411a9c030678d371297b32691da1f6b02c30e0 (patch)
treed85e5c4b5d03c0f2f1ff199c9627644ca3860ae5
parent140332256f2059be7b3a0fdcf082c3bb1f568df4 (diff)
add configuration functions.
* git-difme.scm (load-config, get-config-path, get-difme-repos): new functions.
-rw-r--r--git-difme.scm23
1 files changed, 23 insertions, 0 deletions
diff --git a/git-difme.scm b/git-difme.scm
index 76c35e2..bc999da 100644
--- a/git-difme.scm
+++ b/git-difme.scm
@@ -30,6 +30,29 @@
(close-pipe port)
out-lst))
+;;;; configuration
+(define (load-config path)
+ "load configuration file from PATH.
+
+errors out if PATH does not exists."
+ (if (file-exists? path)
+ (load path)
+ (error "config not found at" path)))
+
+(define (get-config-path)
+ "return configuration file path as a string."
+ (string-append (getenv "HOME") "/.config/git-difme/config"))
+
+(define (get-difme-repos)
+ "return difme repos returned by `difme-repos` function.
+
+`difme-repos` is defined in the configuration file; this function
+loads the configuration file and then evals the `difme-repos`
+function."
+ (let ((path (get-config-path)))
+ (load-config path)
+ (eval '(difme-repos) (interaction-environment))))
+
;;;; main
(define (main srcs)
srcs)