diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-11-29 01:18:39 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-11-29 01:18:39 +0100 |
commit | 01d124ff7a0e62b2597d2b8372d1276fe0257b52 (patch) | |
tree | 317adfca5e9bb4d7a19ddf9acabf8200fe8e0ecb /module/c | |
parent | Found out some inconvinient truths about the format. (diff) | |
download | calp-01d124ff7a0e62b2597d2b8372d1276fe0257b52.tar.gz calp-01d124ff7a0e62b2597d2b8372d1276fe0257b52.tar.xz |
getopt 'options' option on values.
Diffstat (limited to '')
-rw-r--r-- | module/calp/util/options.scm | 19 |
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) |