blob: 587beda36ddb015ec75c0d445478e3790bdd39d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
(define-module (entry-points text)
:export (main)
:use-module (output text)
:use-module (ice-9 getopt-long)
:use-module (util io)
:use-module (util options)
)
(define options
'((width (value #t) (single-char #\w)
(description "Width of written text, defaults to 70 chars."))
(file (value #t) (single-char #\f)
(description (*TOP* "Read from " (i "file") " instead of standard input.")))
(help (single-char #\h)
(description "Prints this help."))))
(define (main args)
(define opts (getopt-long args (getopt-opt options)))
(when (option-ref opts 'help #f)
(print-arg-help options)
(throw 'return))
(for-each (lambda (l) (display l) (newline))
(flow-text
(with-input-from-port (open-input-port (option-ref opts 'file "-"))
(@ (ice-9 rdelim) read-string))
#:width (or (string->number (option-ref opts 'width "")) 70))))
|