aboutsummaryrefslogtreecommitdiff
path: root/deepenv.scm
diff options
context:
space:
mode:
Diffstat (limited to 'deepenv.scm')
-rw-r--r--deepenv.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/deepenv.scm b/deepenv.scm
index 6e81a46..37082ad 100644
--- a/deepenv.scm
+++ b/deepenv.scm
@@ -1,6 +1,23 @@
(import scheme
(chicken base)
(chicken pathname)
+ (chicken file)
+ (chicken io)
+ (chicken string)
+ (srfi srfi-13)
(chicken process-context))
-(decompose-directory (current-directory))
+(define (dir-has-.env? dir)
+ (file-exists? (make-pathname dir ".env")))
+
+(define (read-env-line port)
+ "Read an env-definition line from PORT and return as a cons cell"
+ (let ((line (read-line port)))
+ (string-split line "=")))
+
+(define (load-dir-.env dir)
+ "Load a .env file present in `.dir` and return its environment definitions as a alist"
+ (with-input-from-file ".env"
+ (lambda () (read-list (current-input-port) read-line))))
+
+(letrec ((path-hierarchy (decompose-directory (current-directory)))))