aboutsummaryrefslogtreecommitdiff
path: root/module/calp/util
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-11-29 01:18:39 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-11-29 01:18:39 +0100
commit01d124ff7a0e62b2597d2b8372d1276fe0257b52 (patch)
tree317adfca5e9bb4d7a19ddf9acabf8200fe8e0ecb /module/calp/util
parentFound out some inconvinient truths about the format. (diff)
downloadcalp-01d124ff7a0e62b2597d2b8372d1276fe0257b52.tar.gz
calp-01d124ff7a0e62b2597d2b8372d1276fe0257b52.tar.xz
getopt 'options' option on values.
Diffstat (limited to 'module/calp/util')
-rw-r--r--module/calp/util/options.scm19
1 files changed, 15 insertions, 4 deletions
diff --git a/module/calp/util/options.scm b/module/calp/util/options.scm
index 0e239a78..e7158210 100644
--- a/module/calp/util/options.scm
+++ b/module/calp/util/options.scm
@@ -9,9 +9,15 @@
(cons (car optline)
(map (lambda (opt-field)
(cons (car opt-field)
- (cond [(and (eq? 'value (car opt-field))
- (symbol? (cadr opt-field)))
- '(optional)]
+ (cond [(eq? 'value (car opt-field))
+ (cond [(cadr opt-field)
+ list? => (lambda (opts)
+ (case (car opts)
+ ;; TODO this should also generate a validator
+ ((options) '(#t))
+ (else '(#t))))]
+ [(symbol? (cadr opt-field)) '(optional)]
+ [else (cdr opt-field)])]
[else (cdr opt-field)])))
(lset-intersection (lambda (a b) (eqv? b (car a)))
(cdr optline)
@@ -28,7 +34,12 @@
(let ((valuefmt (case (and=> (assoc-ref args 'value) car)
[(#t) '(" " (i value))]
[(#f) '()]
- [else => (lambda (s) `(" [" (i ,s) "]"))])))
+ [else => (lambda (s)
+ (if (list? s)
+ (case (car s)
+ [(options)
+ `(" {" ,(string-join (cdr s) "|") "}")])
+ `(" [" (i ,s) "]")))])))
`(*TOP* (b "--" ,name) ,@valuefmt
,@(awhen (assoc-ref args 'single-char)
`("," (ws)