From patchwork Sat Dec 3 01:09:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antero Mejr X-Patchwork-Id: 45021 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C98AE27BBEB; Sat, 3 Dec 2022 01:11:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6BD8327BBE9 for ; Sat, 3 Dec 2022 01:11:38 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1H3Z-00085z-Uo; Fri, 02 Dec 2022 20:11:05 -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 1p1H3W-00085W-RW for guix-patches@gnu.org; Fri, 02 Dec 2022 20:11: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 1p1H3W-0007LL-Fl for guix-patches@gnu.org; Fri, 02 Dec 2022 20:11:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1H3W-0008MA-Aq for guix-patches@gnu.org; Fri, 02 Dec 2022 20:11:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag. Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 03 Dec 2022 01:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59754 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59754@debbugs.gnu.org Cc: Antero Mejr Received: via spool by 59754-submit@debbugs.gnu.org id=B59754.167002981632104 (code B ref 59754); Sat, 03 Dec 2022 01:11:02 +0000 Received: (at 59754) by debbugs.gnu.org; 3 Dec 2022 01:10:16 +0000 Received: from localhost ([127.0.0.1]:49993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1H2m-0008Lj-4Q for submit@debbugs.gnu.org; Fri, 02 Dec 2022 20:10:16 -0500 Received: from mout-p-101.mailbox.org ([80.241.56.151]:57560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1H2i-0008LL-Ra for 59754@debbugs.gnu.org; Fri, 02 Dec 2022 20:10:14 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4NPBYl0jxZz9sQD for <59754@debbugs.gnu.org>; Sat, 3 Dec 2022 02:10:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1670029803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1AU0GE+RCcx8cgEO9gmVOjkaGomeUtyAJMm7LWLtAo8=; b=mNHJ6so/sNtt2zfb65rybkbcIpVHHcZJup+7NMklg5eO6SdUcTTxsrp8WhCJYoHxquCMnK eL6hxDcRbrEjdhNPrA+uydLNA+8hwgpLvuOMjviOG1HCgcdHU7fJ9jJDh27SDtZQljt/7k MxYrTV/WVA4+F+0uHpGEsUSIb1n+TPHU9VBJxwpf0ZjHDViFwsDIm0ulLGPXW+Gcmt6mL0 YB+ri3/5NjT7IVA5nYbbqKH5vUW9jOqQRcKlyikrkja2d4KTNLwkdNtbzRyEcT5v1AfpX9 KQLEIA9cPyA1pH/bYoMNBg56cORufO0JeMqgKGwAqpHDmrmSvomQ8fZ+cdYwbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1670029798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1AU0GE+RCcx8cgEO9gmVOjkaGomeUtyAJMm7LWLtAo8=; b=IoHfENZocHkwSsB7895dMeFFZCW1t8aBV14kvj0/yHKY0L1nH9DVnVK58TzHURWhSnf2mZ gYuZDFzNC4Sr5GtaJ/va0nsALkUy2eExKjRlO2MxWz5UdV1i7Aw/BW9mtWs2egMrmFMzB1 4kF/kHZTbUCu8uv+aL3gfI/+drTksXfTVjx8IryknfFDTmKfHAXXOZqzhqP8nSGszWpwiA N6xbTx7FDYImbqzfkk+PrV5IgqG+MV4qcmokQzpsjxP+o+m2ts81zAYl082xgjAGZgkvf6 1+yNH1bnbZ6hRReuk/RZeLQtkm4lneeOdiIIID2Cel/ZeN5zmMBcDu+nJVtQvA== Date: Sat, 3 Dec 2022 01:09:37 +0000 Message-Id: <20221203010937.2332-2-antero@mailbox.org> In-Reply-To: <20221203010937.2332-1-antero@mailbox.org> References: <20221203010937.2332-1-antero@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: r9pbwi8h79mqw8z3bdmaubzgd6765qsr X-MBO-RS-ID: abe8eacb05f5ef2b6c6 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: List-Help: List-Subscribe: , Reply-to: Antero Mejr X-ACL-Warn: , Antero Mejr via Guix-patches X-Patchwork-Original-From: Antero Mejr via Guix-patches via From: Antero Mejr Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/repl.scm (%options): Add -i, --interactive flag. (guix-repl): Honor -i, --interactive flag. * doc/guix.texi (Invoking guix repl): Add documentation for -i, --interactive. --- doc/guix.texi | 12 ++++++++++++ guix/scripts/repl.scm | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index cf9e6f640d..3391c7a66c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11992,6 +11992,14 @@ lines at the top of the script: @code{!#} @end example +To make a script that launches an interactive REPL directly from the +shell, use the @code{--interactive} flag: + +@example +@code{#!/usr/bin/env -S guix repl --interactive} +@code{!#} +@end example + Without a file name argument, a Guile REPL is started, allowing for interactive use (@pxref{Using Guix Interactively}): @@ -12040,6 +12048,10 @@ Accept connections on localhost on port 37146. Accept connections on the Unix-domain socket @file{/tmp/socket}. @end table +@item --interactive +@itemx -i +Launch the interactive REPL after @var{FILE} is executed. + @item --load-path=@var{directory} @itemx -L @var{directory} Add @var{directory} to the front of the package module search path diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm index 0ec62786e9..787c63d48e 100644 --- a/guix/scripts/repl.scm +++ b/guix/scripts/repl.scm @@ -62,6 +62,9 @@ (define %options (option '(#\q) #f #f (lambda (opt name arg result) (alist-cons 'ignore-dot-guile? #t result))) + (option '(#\i "interactive") #f #f + (lambda (opt name arg result) + (alist-cons 'interactive? #t result))) (option '(#\L "load-path") #t #f (lambda (opt name arg result) ;; XXX: Imperatively modify the search paths. @@ -84,6 +87,9 @@ (define (show-help) -q inhibit loading of ~/.guile")) (newline) (display (G_ " + -i, --interactive launch REPL after evaluating FILE")) + (newline) + (display (G_ " -L, --load-path=DIR prepend DIR to the package module search path")) (newline) (display (G_ " @@ -196,7 +202,7 @@ (define script ;; file in %LOAD-PATH. Thus, pass (getcwd) instead of ".". (load-in-vicinity (getcwd) (car script))))) - (when (null? script) + (when (or (null? script) (assoc-ref opts 'interactive?)) ;; Start REPL (let ((type (assoc-ref opts 'type))) (call-with-connection (assoc-ref opts 'listen)