From: Richard Sent <richard@freakingpenguin.com>
To: 74961@debbugs.gnu.org
Cc: "Richard Sent" <richard@freakingpenguin.com>,
"Christopher Baines" <guix@cbaines.net>,
"Josselin Poiret" <dev@jpoiret.xyz>,
"Ludovic Courtès" <ludo@gnu.org>,
"Mathieu Othacehe" <othacehe@gnu.org>,
"Simon Tournier" <zimon.toutoune@gmail.com>,
"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#74961] [PATCH] scripts: deploy: Add the expression command line flag.
Date: Thu, 19 Dec 2024 00:37:52 -0500 [thread overview]
Message-ID: <6a3be28b8325e18076a01b9a9a60d22f4b8b866d.1734586672.git.richard@freakingpenguin.com> (raw)
* guix/scripts/deploy.scm (show-help): Add help.
(%options): Add -e and --expression.
(guix-deploy): Use expression and check for invalid flag combinations.
Change-Id: I200c9ff0c9a8c686efff4a21cd33c10429f3c73e
---
Submitting a patch to take care of https://issues.guix.gnu.org/71841.
Always struck me as odd that deploy doesn't have a --evaluate flag
like many others, so here's a go at it.
I didn't update documentation because "invoking guix deploy" still has
a TODO stating
> @c FIXME/TODO: Separate the API doc from the CLI doc.
As is there doesn't seem to be a good place to insert --expression
documentation without sidetracking the info page.
This'll be useful for me at least as I store my machine list in a
channel.
guix/scripts/deploy.scm | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm
index 4b1a603049..941ee199f0 100644
--- a/guix/scripts/deploy.scm
+++ b/guix/scripts/deploy.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2019 David Thompson <davet@gnu.org>
;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org>
;;; Copyright © 2020-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2024 Richard Sent <richard@freakingpenguin.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -59,6 +60,9 @@ (define (show-help)
-V, --version display version information and exit"))
(newline)
(display (G_ "
+ -e, --expression=EXPR deploy the list of machines EXPR evaluates to"))
+ (newline)
+ (display (G_ "
-x, --execute execute the following command on all the machines"))
(newline)
(display (G_ "
@@ -74,6 +78,9 @@ (define %options
(lambda args
(show-version-and-exit "guix deploy")))
+ (option '(#\e "expression") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'expression arg result)))
(option '(#\n "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
@@ -247,10 +254,16 @@ (define-command (guix-deploy . args)
(opts (parse-command-line args %options (list %default-options)
#:argument-handler handle-argument))
(file (assq-ref opts 'file))
- (machines (and file (load-source-file file)))
+ (expression (assoc-ref opts 'expression))
+ (machines (or (and file (load-source-file file))
+ (and expression (read/eval expression))))
(dry-run? (assoc-ref opts 'dry-run?))
(execute-command? (assoc-ref opts 'execute-command?)))
- (unless file
+ (when (and file expression)
+ (leave (G_ "both '--expression' and a deployment file were provided~%")))
+
+ (unless (or file
+ expression)
(leave (G_ "missing deployment file argument~%")))
(when (and (pair? command) (not execute-command?))
base-commit: 1a62f687e504c67f26693f3bc60a90e503ab4ea9
--
2.46.0
reply other threads:[~2024-12-19 5:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=6a3be28b8325e18076a01b9a9a60d22f4b8b866d.1734586672.git.richard@freakingpenguin.com \
--to=richard@freakingpenguin.com \
--cc=74961@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=ludo@gnu.org \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=zimon.toutoune@gmail.com \
/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).