GNU bug report logs -
#59754
[PATCH] scripts: repl: Add --interactive and --list-types flags.
Previous Next
Reported by: Antero Mejr <antero <at> mailbox.org>
Date: Fri, 2 Dec 2022 02:58:01 UTC
Severity: normal
Tags: patch
Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59754 in the body.
You can then email your comments to 59754 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
ludo <at> gnu.org, guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Fri, 02 Dec 2022 02:58:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Antero Mejr <antero <at> mailbox.org>
:
New bug report received and forwarded. Copy sent to
ludo <at> gnu.org, guix-patches <at> gnu.org
.
(Fri, 02 Dec 2022 02:58:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Fri, 02 Dec 2022 03:37:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 59754 <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Fri, 02 Dec 2022 16:10:02 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
Thanks, nice!
On Fri, 02 Dec 2022 at 02:56, Antero Mejr via Guix-patches via <guix-patches <at> 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Fri, 02 Dec 2022 16:10:04 GMT)
Full text and
rfc822 format available.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Sat, 03 Dec 2022 01:11:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 59754 <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Sat, 03 Dec 2022 01:11:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 59754 <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Sat, 03 Dec 2022 01:13:02 GMT)
Full text and
rfc822 format available.
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
zimoun <zimon.toutoune <at> 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!
Information forwarded
to
guix-patches <at> gnu.org
:
bug#59754
; Package
guix-patches
.
(Sat, 03 Dec 2022 01:13:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
You have taken responsibility.
(Mon, 16 Jan 2023 14:04:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Antero Mejr <antero <at> mailbox.org>
:
bug acknowledged by developer.
(Mon, 16 Jan 2023 14:04:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 59754-done <at> debbugs.gnu.org (full text, mbox):
Hello,
Antero Mejr <antero <at> 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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 14 Feb 2023 12:24:11 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.