all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#59754] [PATCH] scripts: repl: Add --interactive and --list-types flags.
@ 2022-12-02  2:56 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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Antero Mejr via Guix-patches via @ 2022-12-02  2:56 UTC (permalink / raw)
  To: 59754; +Cc: Antero Mejr, ludo

* guix/scripts/repl.scm (guix-repl): Honor -i, --interactive flag.
(%options): Add -i/--interactive and --l/--list-types.
---
 guix/scripts/repl.scm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 50d18c7760..eac3d7264e 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -52,12 +52,19 @@ (define %options
         (option '(#\t "type") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'type (string->symbol arg) result)))
+        (option '(#\l "list-types") #f #f
+                (lambda (opt name arg result)
+                  (display (string-join '("guile" "machine") "\n" 'suffix))
+                  (exit 0)))
         (option '("listen") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'listen arg result)))
         (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.
@@ -78,9 +85,15 @@ (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_ "
+  -l, --list-types       display REPL types and exit"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -190,7 +203,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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#59754] [PATCH] doc: Add new flag information to REPL section.
  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 ` 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:09 ` [bug#59754] [PATCH 1/2] scripts: repl: Add --list-types flag Antero Mejr via Guix-patches via
  2 siblings, 0 replies; 7+ messages in thread
From: Antero Mejr via Guix-patches via @ 2022-12-02  3:35 UTC (permalink / raw)
  To: 59754; +Cc: Antero Mejr

* doc/guix.texi (Invoking guix repl): Add new flag information for
--interactive and --list-types.
---
 doc/guix.texi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 47b805dc7f..ec3cd8127c 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}):
 
@@ -12044,6 +12052,15 @@ Add @var{directory} to the front of the package module search path
 This allows users to define their own packages and make them visible to
 the script or REPL.
 
+@item --interactive
+@itemx -i
+Launch the interactive REPL after @var{FILE} is executed.
+
+@item --list-types
+@itemx -l
+Display the @var{TYPE} options for @command{guix repl --type=TYPE} and
+exit.
+
 @item -q
 Inhibit loading of the @file{~/.guile} file.  By default, that
 configuration file is loaded when spawning a @code{guile} REPL.
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#59754] [PATCH] scripts: repl: Add --interactive and --list-types flags.
  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 ` 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
  2 siblings, 1 reply; 7+ messages in thread
From: zimoun @ 2022-12-02 15:46 UTC (permalink / raw)
  To: 59754; +Cc: ludo, Antero Mejr

Hi,

Thanks, nice!

On Fri, 02 Dec 2022 at 02:56, Antero Mejr via Guix-patches via <guix-patches@gnu.org> wrote:
> * guix/scripts/repl.scm (guix-repl): Honor -i, --interactive flag.
> (%options): Add -i/--interactive and --l/--list-types.
                                      -^
                                  Typo     

The patch LGTM, minor three comments.

 1. I would not use the shortkey -l; only the long one.
 2. I would move --list-types right before -t/--type

--8<---------------cut here---------------start------------->8---
      --list-types       display REPL types and exit
  -t, --type=TYPE        start a REPL of the given TYPE
      --listen=ENDPOINT  listen to ENDPOINT instead of standard input
  -q                     inhibit loading of ~/.guile

  -i, --interactive      launch REPL after evaluating FILE

  -L, --load-path=DIR    prepend DIR to the package module search path

  -h, --help             display this help and exit
  -V, --version          display version information and exit
--8<---------------cut here---------------end--------------->8---

 3. I would split the addition of --list-types and --interactive in two
 separated commits.  But for each option, I would also change the manual
 with the same commit.  Else, please squash this submission. :-)


Cheers,
simon




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#59754] [PATCH 1/2] scripts: repl: Add --list-types flag.
  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:09 ` Antero Mejr via Guix-patches via
  2022-12-03  1:09   ` [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag Antero Mejr via Guix-patches via
  2 siblings, 1 reply; 7+ messages in thread
From: Antero Mejr via Guix-patches via @ 2022-12-03  1:09 UTC (permalink / raw)
  To: 59754; +Cc: Antero Mejr

* guix/scripts/repl.scm (%options): Add --list-types.
* doc/guix.texi (Invoking guix repl): Add documentation for --list-types.
---
 doc/guix.texi         | 4 ++++
 guix/scripts/repl.scm | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 47b805dc7f..cf9e6f640d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12011,6 +12011,10 @@ of Guix.
 The available options are as follows:
 
 @table @code
+@item --list-types
+Display the @var{TYPE} options for @command{guix repl --type=TYPE} and
+exit.
+
 @item --type=@var{type}
 @itemx -t @var{type}
 Start a REPL of the given @var{TYPE}, which can be one of the following:
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 50d18c7760..0ec62786e9 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -52,6 +52,10 @@ (define %options
         (option '(#\t "type") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'type (string->symbol arg) result)))
+        (option '("list-types") #f #f
+                (lambda (opt name arg result)
+                  (display (string-join '("guile" "machine") "\n" 'suffix))
+                  (exit 0)))
         (option '("listen") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'listen arg result)))
@@ -70,6 +74,8 @@ (define (show-help)
   (display (G_ "Usage: guix repl [OPTIONS...] [-- FILE ARGS...]
 In the Guix execution environment, run FILE as a Guile script with
 command-line arguments ARGS.  If no FILE is given, start a Guile REPL.\n"))
+  (display (G_ "
+      --list-types       display REPL types and exit"))
   (display (G_ "
   -t, --type=TYPE        start a REPL of the given TYPE"))
   (display (G_ "
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag.
  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
  2023-01-16 14:03     ` bug#59754: [PATCH] scripts: repl: Add --interactive and --list-types flags Maxim Cournoyer
  0 siblings, 1 reply; 7+ messages in thread
From: Antero Mejr via Guix-patches via @ 2022-12-03  1:09 UTC (permalink / raw)
  To: 59754; +Cc: Antero Mejr

* 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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#59754] [PATCH] scripts: repl: Add --interactive and --list-types flags.
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Antero Mejr via Guix-patches via @ 2022-12-03  1:10 UTC (permalink / raw)
  To: zimoun; +Cc: ludo, antero, 59754


zimoun <zimon.toutoune@gmail.com> writes:

> Hi,
>
> Thanks, nice!
>
> The patch LGTM, minor three comments.

Split up the commits and made the suggested fixes. Thanks for the review!




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#59754: [PATCH] scripts: repl: Add --interactive and --list-types flags.
  2022-12-03  1:09   ` [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag Antero Mejr via Guix-patches via
@ 2023-01-16 14:03     ` Maxim Cournoyer
  0 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2023-01-16 14:03 UTC (permalink / raw)
  To: Antero Mejr; +Cc: zimoun, 59754-done

Hello,

Antero Mejr <antero@mailbox.org> writes:

> * 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.

I've added your copyright to the guix.texi file and made a small
adjustment, as shown below:

--8<---------------cut here---------------start------------->8---
modified   doc/guix.texi
@@ -111,6 +111,7 @@ Copyright @copyright{} 2022 (@*
 Copyright @copyright{} 2022 John Kehayias@*
 Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
 Copyright @copyright{} 2023 Giacomo Leidi@*
+Copyright @copyright{} 2022 Antero Mejr@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -12070,7 +12071,7 @@ Accept connections on the Unix-domain socket @file{/tmp/socket}.
 
 @item --interactive
 @itemx -i
-Launch the interactive REPL after @var{FILE} is executed.
+Launch the interactive REPL after @var{file} is executed.
 
 @item --load-path=@var{directory}
 @itemx -L @var{directory}
--8<---------------cut here---------------end--------------->8---

And pushed!  Thanks for the contribution and to Simon for the review!

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-16 14:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [bug#59754] [PATCH 2/2] scripts: repl: Add -i, --interactive flag Antero Mejr via Guix-patches via
2023-01-16 14:03     ` bug#59754: [PATCH] scripts: repl: Add --interactive and --list-types flags Maxim Cournoyer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.