summaryrefslogtreecommitdiff
path: root/gnbug
diff options
context:
space:
mode:
authorArun Isaac2022-01-30 15:16:15 +0530
committerArun Isaac2022-01-30 15:17:59 +0530
commitdf7b31863f9865953baca7988af9b6573d00cbf1 (patch)
tree77a05abb4b726243ec69b72c955d80c75b0578f1 /gnbug
parentdcf8e91573cf31093c525830e5895c6706b97039 (diff)
downloadgn-gemtext-df7b31863f9865953baca7988af9b6573d00cbf1.tar.gz
gnbug: Support gemtext output.
We will be using this gemtext output in the gemini frontend of the issue tracker. * gnbug (print-issue-to-gemtext): New function. (gnbug-list): Add --format command-line option.
Diffstat (limited to 'gnbug')
-rwxr-xr-xgnbug47
1 files changed, 44 insertions, 3 deletions
diff --git a/gnbug b/gnbug
index d353cf0..96a0afd 100755
--- a/gnbug
+++ b/gnbug
@@ -380,6 +380,35 @@ List recent updates.
" tasks done")))
(newline))
+(define (print-issue-to-gemtext issue-number issue)
+ "Print ISSUE with number ISSUE-NUMBER to gemtext."
+ (format #t "# ~a" (issue-title issue))
+ (unless (null? (issue-keywords issue))
+ (format #t " [~a]"
+ (string-join (issue-keywords issue)
+ ", ")))
+ (unless (null? (issue-assigned issue))
+ (format #t " (assigned: ~a)"
+ (string-join (issue-assigned issue)
+ ", ")))
+ (when (> (issue-posts issue) 1)
+ (format #t " [~a posts]" (issue-posts issue)))
+ (newline)
+ (format #t "~a opened ~a by ~a"
+ issue-number
+ (issue-created-relative-date issue)
+ (issue-creator issue))
+ (when (> (issue-posts issue) 1)
+ (format #t ", last updated ~a by ~a"
+ (issue-last-updated-relative-date issue)
+ (issue-last-updater issue)))
+ (unless (zero? (issue-tasks issue))
+ (format #t "; ~a/~a tasks done"
+ (issue-completed-tasks issue)
+ (issue-tasks issue)))
+ (newline)
+ (newline))
+
(define gnbug-list
(match-lambda*
(("--help")
@@ -387,6 +416,7 @@ List recent updates.
List issues.
--assigned=ASSIGNED only list issues assigned to ASSIGNED
+ --format=FORMAT output in FORMAT (either text or gemtext, and text by default)
"
(command-line-program)))
@@ -394,10 +424,18 @@ List issues.
(let ((args (args-fold args
(list (option (list "assigned") #t #f
(lambda (opt name arg loads)
- (acons 'assigned arg loads))))
+ (acons 'assigned arg loads)))
+ (option (list "format") #t #f
+ (lambda (opt name arg loads)
+ (acons 'format
+ (cond
+ ((string=? arg "text") 'text)
+ ((string=? arg "gemtext") 'gemtext)
+ (else (error "Unknown format" arg)))
+ loads))))
invalid-option
invalid-operand
- '())))
+ '((format . text)))))
(format #t "~%total ~a~%"
(list-transduce (compose (tenumerate 1)
(tfilter (match-lambda
@@ -408,7 +446,10 @@ List issues.
(issue-assigned issue)))))))
(tlog (match-lambda*
((_ (index . issue))
- (print-issue index issue)))))
+ ((case (assq-ref args 'format)
+ ((text) print-issue)
+ ((gemtext) print-issue-to-gemtext))
+ index issue)))))
rcount
(issues)))))))