From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yGPuEpUR9GNXxwAAbAwnHQ (envelope-from ) for ; Tue, 21 Feb 2023 01:34:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id uNNDEpUR9GOlzAAAG6o9tA (envelope-from ) for ; Tue, 21 Feb 2023 01:34:29 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 01A01375B3 for ; Tue, 21 Feb 2023 01:34:28 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=RyiyifZU; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676939669; a=rsa-sha256; cv=none; b=LzcuqCd+3zYyeJIQD2N5hrFel3AbxS8i4Q30MIUT09a0wE6rC9ZydzB9u0qzBJaqOR4NU1 XIZdwqktJP1gQHXyArLZ/piaU95KnZO7oZp4/o6W1xloUuRwP0epr8UZrVevT1Ch/GLt+D x7BT9w6ycRPy7bL9eAAM3v9ZDRVOyVn+1It2snOP0Pf4O+ctpGrsN2gtVgoffACp07Fdrq Y3e0rw7VghLF5ELoTmUd+QrrBUEXCMl9TqmA2mAPYu3U5gs2WBLdcf01ZvW/wiHC5u5/Wn IA3Lh2GMtu8idCPKCuUWjYRlai21P2DvuLH2sqEWpVxx4KrtNXMY1+NigNZQ+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=RyiyifZU; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676939669; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qfNWu0Oop1RcJ7QtPPWyuUgNlOZOlR0cGxSPLP4LHjU=; b=Jpl3pKmEKNVQf/uW2jdaYD2/mg0IUJ2EyHfqYr6qwhgPLShuxsAJp/nWL/nyC0OtCaDMzu UsDhhDddevJwgnryJ9OIFdJ3Oe+PeBfXA+fGajpvLR3TFY8AeMp41VPre1nz5Rklnlelaf pYZ2PL5R1H0TdptEdDHVh2q1Sgb1scA5d+4SCIMCzPEinhmPYzk5pFTxGeyNek1KUDBBvA f1qxeuN4QEhNN1InrM+eHDy5U5rCYX4l1ghJAdYq1yLTj39fOzmbv5SxZz2z8WVA4LgmWw UkzH3Nn+Rnwh9qmDOH6z/RTHExM6NWg7q8x2ACmdlmJPdNJfATTFbLB/JcH7TQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUGbc-0001ZE-OB; Mon, 20 Feb 2023 19:34:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUGba-0001YR-LZ for guix-patches@gnu.org; Mon, 20 Feb 2023 19:34:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUGba-0005E4-B0 for guix-patches@gnu.org; Mon, 20 Feb 2023 19:34:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pUGba-0002rF-6v for guix-patches@gnu.org; Mon, 20 Feb 2023 19:34:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61645] [PATCH v2 2/4] client: Support checking in to a specific issue. References: <20230220013821.27440-1-arunisaac@systemreboot.net> In-Reply-To: <20230220013821.27440-1-arunisaac@systemreboot.net> Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Feb 2023 00:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61645 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61645@debbugs.gnu.org Cc: Ricardo Wurmus , Arun Isaac Received: via spool by 61645-submit@debbugs.gnu.org id=B61645.167693962010933 (code B ref 61645); Tue, 21 Feb 2023 00:34:02 +0000 Received: (at 61645) by debbugs.gnu.org; 21 Feb 2023 00:33:40 +0000 Received: from localhost ([127.0.0.1]:53935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUGbE-0002qH-BG for submit@debbugs.gnu.org; Mon, 20 Feb 2023 19:33:40 -0500 Received: from mugam.systemreboot.net ([139.59.75.54]:53700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUGbC-0002q6-AX for 61645@debbugs.gnu.org; Mon, 20 Feb 2023 19:33:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qfNWu0Oop1RcJ7QtPPWyuUgNlOZOlR0cGxSPLP4LHjU=; b=RyiyifZU5LRSV/YANr5c4jOory Rsq20rS2x+rnDbYDKwFbZ4svLJCJ1LIEVQr2LKMUERPF01APmESImFBR10yITcJnsD5P7LXSLWB7+ j1dWZlNxPWP1wgcZmEV80wqK8Gf8u/3tDxlZQEEBDnwzVlzz79FVsU/E8+vv9/Ku+kUbcxEPG2zWN /XbNutyJTRIRBOacRDyZ5roIDcCzyqOfcdf2LYw8IR6+4Y5r4OakOC7MeF8NZQ9uJFtM8JD1v7VB7 T4YZ2DpUCrWt2Rbb7FuNgNf0dgNi0nl/r3Xw6ssoEIfCPo1CuL/NQP9duJioAf2yeR5HvK6tUwEHv Sno/CcUA==; Received: from [192.168.2.1] (port=36420 helo=steel.lan) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pUGb7-0009Ub-1c; Tue, 21 Feb 2023 06:03:34 +0530 From: Arun Isaac Date: Tue, 21 Feb 2023 00:33:26 +0000 Message-Id: <20230221003326.5353-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 01A01375B3 X-Spam-Score: 0.15 X-Migadu-Spam-Score: 0.15 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: Kscir1peOGut * 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