From: Arun Isaac <arunisaac@systemreboot.net>
To: 61645@debbugs.gnu.org
Cc: Ricardo Wurmus <rekado@elephly.net>,
Arun Isaac <arunisaac@systemreboot.net>
Subject: [bug#61645] [PATCH v2 2/4] client: Support checking in to a specific issue.
Date: Tue, 21 Feb 2023 00:33:26 +0000 [thread overview]
Message-ID: <20230221003326.5353-1-arunisaac@systemreboot.net> (raw)
In-Reply-To: <20230220013821.27440-1-arunisaac@systemreboot.net>
* mumi/client.scm: Import (srfi srfi-26).
(current-issue-file, current-issue-number): New functions.
(print-current-issue, set-current-issue!, clear-current-issue!): New
public functions.
* scripts/mumi.in (show-mumi-usage): Document current and new
subcommands.
(main): Add current and new subcommands.
---
mumi/client.scm | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
scripts/mumi.in | 20 ++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/mumi/client.scm b/mumi/client.scm
index e4a0123..ae3a0a9 100644
--- a/mumi/client.scm
+++ b/mumi/client.scm
@@ -18,13 +18,17 @@
(define-module (mumi client)
#:use-module (srfi srfi-19)
+ #:use-module (srfi srfi-26)
#:use-module (srfi srfi-43)
#:use-module (term ansi-color)
#:use-module (web uri)
#:use-module (kolam http)
#:use-module (mumi config)
#:use-module (mumi web view utils)
- #:export (search))
+ #:export (search
+ print-current-issue
+ set-current-issue!
+ clear-current-issue!))
(define (git-top-level)
"Return the top-level directory of the current git repository."
@@ -106,3 +110,45 @@
date
(submitter name address)))))
"issues")))
+
+(define (current-issue-file)
+ "Return path to current issue number file."
+ (string-append (client-config-directory) "/current-issue"))
+
+(define (current-issue-number)
+ "Return current issue number."
+ (let ((issue-file (current-issue-file)))
+ (and (file-exists? issue-file)
+ (call-with-input-file issue-file
+ read))))
+
+(define (print-current-issue)
+ "Print current issue."
+ (let ((issue-number (current-issue-number)))
+ (if issue-number
+ (list-issue
+ (assoc-ref
+ (graphql-http-get (graphql-endpoint)
+ `(document
+ (query (#(issue #:number ,issue-number)
+ number
+ title
+ open
+ date
+ (submitter name address)))))
+ "issue"))
+ (begin
+ (format (current-error-port) "No current issue!~%")
+ (exit #f)))))
+
+(define (set-current-issue! issue-number)
+ "Set current issue number."
+ ;; TODO: Write file atomically.
+ (call-with-output-file (current-issue-file)
+ (cut write issue-number <>)))
+
+(define (clear-current-issue!)
+ "Clear current issue."
+ (let ((issue-file (current-issue-file)))
+ (when (file-exists? issue-file)
+ (delete-file issue-file))))
diff --git a/scripts/mumi.in b/scripts/mumi.in
index 9b61729..dfd082d 100644
--- a/scripts/mumi.in
+++ b/scripts/mumi.in
@@ -120,6 +120,12 @@
`mumi search QUERY':
search mumi for issues.
+ `mumi current [ISSUE-NUMBER]':
+ print or set current issue.
+
+ `mumi new':
+ clear current issue presumably to open a new one.
+
`mumi web [--address=address] [--port=port] [--listen-repl[=port]] [--disable-mailer]':
start the application web server.
@@ -138,6 +144,20 @@
(match (cdr (program-arguments))
(("search" . query-strings)
(client:search (string-join query-strings)))
+ (("current")
+ (client:print-current-issue))
+ (("current" issue-number-string)
+ (let ((issue-number (string->number issue-number-string)))
+ (if issue-number
+ (client:set-current-issue! issue-number)
+ (begin
+ (format (current-error-port)
+ "Invalid issue number `~a'~%"
+ issue-number-string)
+ (exit #f))))
+ (client:print-current-issue))
+ (("new")
+ (client:clear-current-issue!))
(("mailer" . rest)
(let* ((opts (parse-options rest))
(sender (assoc-ref opts 'sender))
--
2.38.1
next prev parent reply other threads:[~2023-02-21 0:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 1:38 [bug#61645] [PATCH mumi 0/1] Add CLI client to search for issues Arun Isaac
2023-02-20 1:41 ` [bug#61645] [PATCH mumi 1/1] client: " Arun Isaac
2023-02-21 0:32 ` [bug#61645] [PATCH v2 0/4] Add mumi CLI client Arun Isaac
2023-02-21 0:33 ` [bug#61645] [PATCH v2 1/4] client: Add CLI client to search for issues Arun Isaac
2023-02-21 0:33 ` Arun Isaac [this message]
2023-02-21 0:33 ` [bug#61645] [PATCH v2 3/4] client: Support sending email to issues Arun Isaac
2023-02-21 0:33 ` [bug#61645] [PATCH v2 4/4] Set only GUILE_LOAD_PATH when running tests Arun Isaac
2023-03-08 12:05 ` [bug#61645] [PATCH mumi 0/1] Add CLI client to search for issues Ludovic Courtès
2023-03-08 13:28 ` Arun Isaac
2023-03-08 15:36 ` [bug#61645] [mumi v3 0/4] Add mumi CLI client Arun Isaac
2023-03-08 15:36 ` [bug#61645] [mumi v3 1/4] client: Add CLI client to search for issues Arun Isaac
2023-03-08 15:36 ` [bug#61645] [mumi v3 2/4] client: Support checking in to a specific issue Arun Isaac
2023-03-08 15:36 ` [bug#61645] [mumi v3 3/4] client: Support sending email to issues Arun Isaac
2023-03-08 15:36 ` [bug#61645] [mumi v3 4/4] Set only GUILE_LOAD_PATH when running tests Arun Isaac
2023-03-30 20:47 ` [bug#61645] [PATCH mumi 0/1] Add CLI client to search for issues Ludovic Courtès
2023-03-30 20:57 ` Ricardo Wurmus
2023-03-30 21:57 ` bug#61645: " Ricardo Wurmus
2023-03-31 12:15 ` [bug#61645] " Ludovic Courtès
2023-03-31 20:32 ` Arun Isaac
2023-03-31 22:15 ` Ludovic Courtès
2023-03-31 22:51 ` Arun Isaac
2023-04-01 17:32 ` Arun Isaac
2023-04-24 14:41 ` Arun Isaac
2023-04-24 20:01 ` Ludovic Courtès
2023-04-25 12:28 ` Arun Isaac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230221003326.5353-1-arunisaac@systemreboot.net \
--to=arunisaac@systemreboot.net \
--cc=61645@debbugs.gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).