aboutsummaryrefslogtreecommitdiff
path: root/module/main.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-06-10 22:55:01 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-06-10 22:55:01 +0200
commita01cdf7896815a3ade9ddb03d091a66c3b910549 (patch)
tree03fa9518ce36ce8b58f3fb51f6e96f2cce676e2e /module/main.scm
parentNote that --field for benchmark is required. (diff)
downloadcalp-a01cdf7896815a3ade9ddb03d091a66c3b910549.tar.gz
calp-a01cdf7896815a3ade9ddb03d091a66c3b910549.tar.xz
Add --config flag.
Diffstat (limited to 'module/main.scm')
-rw-r--r--module/main.scm20
1 files changed, 15 insertions, 5 deletions
diff --git a/module/main.scm b/module/main.scm
index aa4a2dac..4067bd82 100644
--- a/module/main.scm
+++ b/module/main.scm
@@ -51,7 +51,9 @@
(br)
(b "Should NOT be used in production.")))
- ;; TODO --config flag for loading alternate configuration file.
+ (config (value #t)
+ (description
+ "Path to alterantive configuration file to load instead of the default one. "))
;; Techical note:
;; Guile's getopt doesn't support repeating keys. Thereby the small jank,
@@ -110,16 +112,24 @@
(define opts (getopt-long args (getopt-opt options) #:stop-at-first-non-option #t))
(define stprof (option-ref opts 'statprof #f))
(define repl (option-ref opts 'repl #f))
+ (define altconfig (option-ref opts 'config #f))
(when stprof (statprof-start))
(cond [(eqv? #t repl) (repl-start (format #f "~a/calp-~a" (runtime-dir) (getpid)))]
[repl => repl-start])
- (let ((config-file (format #f "~a/.config/calp/config.scm"
- (getenv "HOME"))))
- (when (file-exists? config-file)
- (primitive-load config-file)))
+ (if altconfig
+ (begin
+ (if (file-exists? altconfig)
+ (primitive-load altconfig)
+ (throw 'option-error "Configuration file ~a missing" altconfig)))
+ ;; if not altconfig, then regular config
+ (let ((config-file (format #f "~a/.config/calp/config.scm"
+ (getenv "HOME"))))
+ (when (file-exists? config-file)
+ (primitive-load config-file))))
+
;; TODO this doesn't stop at first non-option, meaning that -o flags
;; from sub-commands might be parsed.