aboutsummaryrefslogtreecommitdiff
path: root/module/calp/entry-points/text.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/calp/entry-points/text.scm')
-rw-r--r--module/calp/entry-points/text.scm29
1 files changed, 29 insertions, 0 deletions
diff --git a/module/calp/entry-points/text.scm b/module/calp/entry-points/text.scm
new file mode 100644
index 00000000..04f57a31
--- /dev/null
+++ b/module/calp/entry-points/text.scm
@@ -0,0 +1,29 @@
+(define-module (calp entry-points text)
+ :export (main)
+ :use-module (text flow)
+ :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 "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))))