aboutsummaryrefslogtreecommitdiff
path: root/module/util/options.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-24 20:34:11 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-24 20:34:11 +0200
commitd3afa54144748685d12c159407194e03538e98de (patch)
tree7a260d6ed4e52e2e1c72729a0922551e3790ba97 /module/util/options.scm
parent. (diff)
downloadcalp-d3afa54144748685d12c159407194e03538e98de.tar.gz
calp-d3afa54144748685d12c159407194e03538e98de.tar.xz
Move util modules into calp module..
Diffstat (limited to 'module/util/options.scm')
-rw-r--r--module/util/options.scm48
1 files changed, 0 insertions, 48 deletions
diff --git a/module/util/options.scm b/module/util/options.scm
deleted file mode 100644
index a4c780bc..00000000
--- a/module/util/options.scm
+++ /dev/null
@@ -1,48 +0,0 @@
-(define-module (util options)
- :use-module (util)
- :use-module (srfi srfi-1)
-)
-
-;; option-assoc → getopt-valid option-assoc
-(define-public (getopt-opt options)
- (map (lambda (optline)
- (cons (car optline)
- (map (lambda (opt-field)
- (cons (car opt-field)
- (cond [(and (eq? 'value (car opt-field))
- (symbol? (cadr opt-field)))
- '(optional)]
- [else (cdr opt-field)])))
- (lset-intersection (lambda (a b) (eqv? b (car a)))
- (cdr optline)
- '(single-char required? value predicate)))))
- options))
-
-
-
-
-;; (name (key value) ...) → sxml
-(define (fmt-help option-line)
- (let ((name (car option-line))
- (args (cdr option-line)))
- (let ((valuefmt (case (and=> (assoc-ref args 'value) car)
- [(#t) '(" " (i value))]
- [(#f) '()]
- [else => (lambda (s) `(" [" (i ,s) "]"))])))
- `(*TOP* (b "--" ,name) ,@valuefmt
- ,@(awhen (assoc-ref args 'single-char)
- `("," (ws)
- (b "-" ,(car it))
- ,@valuefmt))
- (br)
- ,@(awhen (assoc-ref args 'description)
- `((blockquote ,@it)
- (br)))))))
-
-(use-modules (text markup))
-
-(define-public (format-arg-help options)
- (sxml->ansi-text (cons '*TOP* (map sxml->ansi-text (map fmt-help options)))))
-
-(define*-public (print-arg-help options optional: (port (current-error-port)))
- (display (format-arg-help options) port))