aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-04-11 19:03:55 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-04-11 19:12:30 +0200
commit0ac7b141f833296e229f0daabe5b4274adf681f3 (patch)
treea5dc9a4fc5b5faaff183117e53f8f02da364fbae /scripts
parentAllow translation of non-extracted strings. (diff)
downloadcalp-0ac7b141f833296e229f0daabe5b4274adf681f3.tar.gz
calp-0ac7b141f833296e229f0daabe5b4274adf681f3.tar.xz
Rewrote script get-config.
Now works with new config system. Also outputs result as an ini-file.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get-config.scm80
1 files changed, 31 insertions, 49 deletions
diff --git a/scripts/get-config.scm b/scripts/get-config.scm
index f1088c8e..7d6abfcd 100755
--- a/scripts/get-config.scm
+++ b/scripts/get-config.scm
@@ -9,61 +9,43 @@
(add-to-load-path "module")
+(add-to-load-path "scripts")
(use-modules
(hnh util)
(ice-9 ftw)
(ice-9 match)
(srfi srfi-1)
- )
-
-(define (read-multiple)
- (let loop ((done '()))
- (let ((sexp (read)))
- (if (eof-object? sexp)
- (reverse done)
- (loop (cons sexp done))))))
-
-(define remove-stat
- (match-lambda
- ((name state) name)
- ((name stat children ...)
- (cons name (map remove-stat children)))))
+ (srfi srfi-88)
-(define (f tree)
- (let loop ((rem tree) (path '()))
- (cond [(string? rem)
- (string-join (reverse (cons rem path)) "/" 'infix)]
- [(null? rem)
- '()]
- [else
- (map (lambda (branch)
- (loop branch (cons (car rem) path)))
- (cdr rem))])))
+ (all-modules)
+ (module-introspection)
+ ((calp translation)
+ :select (translate))
+ )
-((@ (ice-9 pretty-print) pretty-print)
- (filter
- (lambda (form)
- (and (list? form) (not (null? form))
- (eq? 'define-config (car form))))
- (concatenate
- (map (lambda (filename) (with-input-from-file filename read-multiple))
- (flatten (f (remove-stat (file-system-tree "module"))))))))
-
-;; expected result =>
-#;
-((config debug)
- (config edit-mode)
- (config summary-filter)
- (config description-filter)
- (config
- tz-dir
- "Directory in which zoneinfo files can be found")
- (config
- tz-list
- "List of default zoneinfo files to be parsed")
- (config default-week-start "First day of week")
- (config
- calendar-files
- "Which files to parse. Takes a list of paths or a single string which will be globbed."))
+;; TODO split this into separate read and write stages
+;; TODO and add texinfo output (besides ini output)
+(for (filename module-name)
+ in (all-files-and-modules-under-directory "module")
+ (define forms (call-with-input-file filename get-forms))
+ (define configurations
+ (filter (lambda (form)
+ (and (list? form) (not (null? form))
+ (eq? 'define-config (car form))))
+ forms))
+ (unless (null? configurations)
+ (format #t "~%[~{~a~^ ~}]" module-name)
+ (for-each (match-lambda
+ (('define-config name default kvs ...)
+ (cond ((memv description: kvs)
+ => (match-lambda
+ ((description: ('_ desc) rest ...)
+ (format #t "~%; ~a"
+ (gettext desc "calp")))
+ ((description: desc rest ...)
+ (format #t "~%; ~a" desc)))))
+ (format #t "~%~a = ~s~%"
+ name default)))
+ configurations)))