summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-25 14:20:11 +0530
committerArun Isaac2022-06-25 14:20:11 +0530
commitdab0cba73f3dcafbb5b5234847b041f141c28069 (patch)
treec5f1fb1a58f0a77b5849a7da1a50592cb4bc7366
parent993aec0b17086cc4681fbf234aa19f4710fff441 (diff)
downloadtissue-dab0cba73f3dcafbb5b5234847b041f141c28069.tar.gz
tissue-dab0cba73f3dcafbb5b5234847b041f141c28069.tar.lz
tissue-dab0cba73f3dcafbb5b5234847b041f141c28069.zip
bin: Expect filename arguments to `tissue show'.
* bin/tissue (tissue-show): Expect filename arguments instead of issue numbers.
-rwxr-xr-xbin/tissue98
1 files changed, 48 insertions, 50 deletions
diff --git a/bin/tissue b/bin/tissue
index 5b63789..e4be831 100755
--- a/bin/tissue
+++ b/bin/tissue
@@ -233,59 +233,57 @@ export EDITOR=emacsclient"))
(define tissue-show
(match-lambda*
(("--help")
- (format #t "Usage: ~a show ISSUE-NUMBER
-Show the text of issue #ISSUE-NUMBER.
+ (format #t "Usage: ~a show FILE
+Show the text of FILE.
"
(command-line-program)))
- ((issue-number)
- (let ((issue-file (issue-file (list-ref (issues)
- (1- (string->number issue-number))))))
- ;; Files may be renamed or deleted, but not
- ;; committed. Therefore, only read the file if it exists.
- (if (file-exists? issue-file)
- (call-with-input-file (issue-file issue)
- (lambda (port)
- (port-transduce
- (compose
- ;; Detect preformatted text blocks.
- (tfold (match-lambda*
- (((pre? . _) line)
- (cons (if (string-prefix? "```" line)
- (not pre?)
- pre?)
- line)))
- (cons #f #f))
- (tmap (lambda (pre?+line)
- (match pre?+line
- ((pre? . line)
- (cond
- ;; Print headlines in bold.
- ((string-prefix? "#" line)
- (display (colorize-string line 'BOLD)))
- ;; Print lists in cyan.
- ((string-prefix? "*" line)
- (display (colorize-string line 'CYAN)))
- ;; Print links in cyan, but only the actual
- ;; link, and not the => prefix or the label.
- ((string-match "^(=>[ \t]*)([^ ]*)([^\n]*)" line)
- => (lambda (m)
- (display (match:substring m 1))
- (display (colorize-string (match:substring m 2) 'CYAN))
- (display (match:substring m 3))))
- ;; Print preformatted text backticks in
- ;; magenta.
- ((string-prefix? "```" line)
- (display (colorize-string line 'MAGENTA)))
- (else
- ;; If part of preformatted block, print in
- ;; magenta. Else, print in default color.
- (display (if pre? (colorize-string line 'MAGENTA) line))))))
- (newline))))
- (const #t)
- get-line-dos-or-unix
- port)))
- (raise (issue-file-not-found-error issue-file)))))))
+ ((file)
+ ;; Files may be renamed or deleted, but not committed. Therefore,
+ ;; only read the file if it exists.
+ (if (file-exists? file)
+ (call-with-input-file file
+ (lambda (port)
+ (port-transduce
+ (compose
+ ;; Detect preformatted text blocks.
+ (tfold (match-lambda*
+ (((pre? . _) line)
+ (cons (if (string-prefix? "```" line)
+ (not pre?)
+ pre?)
+ line)))
+ (cons #f #f))
+ (tmap (lambda (pre?+line)
+ (match pre?+line
+ ((pre? . line)
+ (cond
+ ;; Print headlines in bold.
+ ((string-prefix? "#" line)
+ (display (colorize-string line 'BOLD)))
+ ;; Print lists in cyan.
+ ((string-prefix? "*" line)
+ (display (colorize-string line 'CYAN)))
+ ;; Print links in cyan, but only the actual
+ ;; link, and not the => prefix or the label.
+ ((string-match "^(=>[ \t]*)([^ ]*)([^\n]*)" line)
+ => (lambda (m)
+ (display (match:substring m 1))
+ (display (colorize-string (match:substring m 2) 'CYAN))
+ (display (match:substring m 3))))
+ ;; Print preformatted text backticks in
+ ;; magenta.
+ ((string-prefix? "```" line)
+ (display (colorize-string line 'MAGENTA)))
+ (else
+ ;; If part of preformatted block, print in
+ ;; magenta. Else, print in default color.
+ (display (if pre? (colorize-string line 'MAGENTA) line))))))
+ (newline))))
+ (const #t)
+ get-line-dos-or-unix
+ port)))
+ (raise (issue-file-not-found-error file))))))
(define load-config
(memoize-thunk