unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Antero Mejr via Guix-patches via <guix-patches@gnu.org>
To: 59754@debbugs.gnu.org
Cc: Antero Mejr <antero@mailbox.org>
Subject: [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag.
Date: Sat,  3 Dec 2022 01:09:37 +0000	[thread overview]
Message-ID: <20221203010937.2332-2-antero@mailbox.org> (raw)
In-Reply-To: <20221203010937.2332-1-antero@mailbox.org>

* 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)
-- 
2.38.1





  reply	other threads:[~2022-12-03  1:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  2:56 [bug#59754] [PATCH] scripts: repl: Add --interactive and --list-types flags Antero Mejr via Guix-patches via
2022-12-02  3:35 ` [bug#59754] [PATCH] doc: Add new flag information to REPL section Antero Mejr via Guix-patches via
2022-12-02 15:46 ` [bug#59754] [PATCH] scripts: repl: Add --interactive and --list-types flags zimoun
2022-12-03  1:10   ` Antero Mejr via Guix-patches via
2022-12-03  1:09 ` [bug#59754] [PATCH 1/2] scripts: repl: Add --list-types flag Antero Mejr via Guix-patches via
2022-12-03  1:09   ` Antero Mejr via Guix-patches via [this message]
2023-01-16 14:03     ` bug#59754: [PATCH] scripts: repl: Add --interactive and --list-types flags Maxim Cournoyer

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=20221203010937.2332-2-antero@mailbox.org \
    --to=guix-patches@gnu.org \
    --cc=59754@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    /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).