Adds --outdir option (maildir output) to UNIX client
This commit is contained in:
parent
60e301edf8
commit
ad3d36b0b7
|
@ -364,19 +364,14 @@
|
||||||
'((help
|
'((help
|
||||||
"Print a usage message"
|
"Print a usage message"
|
||||||
(single-char #\h))
|
(single-char #\h))
|
||||||
;; (outdir
|
(outdir
|
||||||
;; "Output directory, used for multi-file templates (e.g., maildir)"
|
"Output directory, used for maildir output"
|
||||||
;; (single-char #\d)
|
(single-char #\d)
|
||||||
;; (value (required DIR)))
|
(value (required DIR)))
|
||||||
(output
|
(output
|
||||||
"Output file, used for single-file templates (e.g., mbox). Defaults to stdout."
|
"Output file, used for mbox output. Default is stdout."
|
||||||
(single-char #\o)
|
(single-char #\o)
|
||||||
(value (required FILE)))))
|
(value (required FILE)))))
|
||||||
;; (template
|
|
||||||
;; "Output template for feed ('mbox' or 'maildir'). Defaults to 'mbox'."
|
|
||||||
;; (single-char #\t)
|
|
||||||
;; (value (required TEMPLATE)))))
|
|
||||||
;; The user's presumed config root.
|
|
||||||
|
|
||||||
|
|
||||||
;; Prints cli usage to stderr.
|
;; Prints cli usage to stderr.
|
||||||
|
@ -389,17 +384,19 @@
|
||||||
;; TODO: accept piped-in feeds
|
;; TODO: accept piped-in feeds
|
||||||
(define (main)
|
(define (main)
|
||||||
(let* ([args (getopt-long (command-line-arguments) *opts*)]
|
(let* ([args (getopt-long (command-line-arguments) *opts*)]
|
||||||
[output (alist-ref 'output args)])
|
[output-dir (alist-ref 'outdir args)]
|
||||||
|
[output (or (alist-ref 'output args) output-dir)]
|
||||||
|
[template (if output-dir *maildir-template* *mbox-template*)])
|
||||||
(if (alist-ref 'help args)
|
(if (alist-ref 'help args)
|
||||||
(help)
|
(help)
|
||||||
(map (lambda (free-arg)
|
(map (lambda (free-arg)
|
||||||
(cond [(not (file-exists? free-arg))
|
(cond [(not (file-exists? free-arg))
|
||||||
#f]
|
#f]
|
||||||
[output
|
[output
|
||||||
(write-entries-to-file (all-entries free-arg) *mbox-template* output)]
|
(write-entries-to-file (all-entries free-arg) template output)]
|
||||||
[(not output)
|
[(not output)
|
||||||
(map (lambda (entry)
|
(map (lambda (entry)
|
||||||
(write-entry entry *mbox-template*
|
(write-entry entry template
|
||||||
(open-output-file* fileno/stdout)))
|
(open-output-file* fileno/stdout)))
|
||||||
(all-entries free-arg))]))
|
(all-entries free-arg))]))
|
||||||
(alist-ref '@ args)))))
|
(alist-ref '@ args)))))
|
||||||
|
|
Ŝarĝante…
Reference in New Issue