diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-10 22:55:01 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-10 22:55:01 +0200 |
commit | a01cdf7896815a3ade9ddb03d091a66c3b910549 (patch) | |
tree | 03fa9518ce36ce8b58f3fb51f6e96f2cce676e2e | |
parent | Note that --field for benchmark is required. (diff) | |
download | calp-a01cdf7896815a3ade9ddb03d091a66c3b910549.tar.gz calp-a01cdf7896815a3ade9ddb03d091a66c3b910549.tar.xz |
Add --config flag.
Diffstat (limited to '')
-rw-r--r-- | module/main.scm | 20 |
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. |