From: Martin Becze <mjbecze@riseup.net>
To: 37525@debbugs.gnu.org
Cc: Martin Becze <mjbecze@riseup.net>
Subject: [bug#37525] [PATCH v2 2/3] updated the crate import script to accept recursive option
Date: Tue, 1 Oct 2019 16:54:57 -0400 [thread overview]
Message-ID: <20191001205458.20926-2-mjbecze@riseup.net> (raw)
In-Reply-To: <20191001205458.20926-1-mjbecze@riseup.net>
* guix/scripts/import/crate.scm (show-help, guix-import-crate): added recursive option
---
guix/scripts/import/crate.scm | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 7ae8638911..19c8277d14 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -28,6 +28,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-37)
+ #:use-module (srfi srfi-41)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:export (guix-import-crate))
@@ -46,6 +47,8 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(display (G_ "
-h, --help display this help and exit"))
(display (G_ "
+ -r, --recursive import packages recursively"))
+ (display (G_ "
-V, --version display version information and exit"))
(newline)
(show-bug-report-information))
@@ -59,6 +62,9 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(option '(#\V "version") #f #f
(lambda args
(show-version-and-exit "guix import crate")))
+ (option '(#\r "recursive") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'recursive #t result)))
%standard-import-options))
\f
@@ -79,22 +85,31 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(let* ((opts (parse-options))
(args (filter-map (match-lambda
- (('argument . value)
- value)
- (_ #f))
+ (('argument . value)
+ value)
+ (_ #f))
(reverse opts))))
(match args
((spec)
(define-values (name version)
(package-name->name+version spec))
- (let ((sexp (crate->guix-package name version)))
- (unless sexp
- (leave (G_ "failed to download meta-data for package '~a'~%")
- (if version
- (string-append name "@" version)
- name)))
- sexp))
+ (if (assoc-ref opts 'recursive)
+ (map (match-lambda
+ ((and ('package ('name name) . rest) pkg)
+ `(define-public ,(string->symbol name)
+ ,pkg))
+ (_ #f))
+ (reverse
+ (stream->list
+ (crate-recursive-import name))))
+ (let ((sexp (crate->guix-package name version)))
+ (unless sexp
+ (leave (G_ "failed to download meta-data for package '~a'~%")
+ (if version
+ (string-append name "@" version)
+ name)))
+ sexp)))
(()
(leave (G_ "too few arguments~%")))
((many ...)
--
2.23.0
next prev parent reply other threads:[~2019-10-01 20:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-26 18:28 [bug#37525] [PATCH 0/3] Recursive option for crate importer Martin Becze
2019-09-26 18:31 ` [bug#37525] [PATCH 1/3] added recusive import functionality to the " Martin Becze
2019-09-26 18:31 ` [bug#37525] [PATCH 2/3] updated the crate import script to accept recursive option Martin Becze
2019-09-26 18:31 ` [bug#37525] [PATCH 3/3] updated docs for import crate Martin Becze
2019-10-01 20:17 ` [bug#37525] previous patch had mistake in docs Martin Becze
2019-10-01 20:54 ` [bug#37525] [PATCH v2 1/3] added recusive import functionality to the crate importer Martin Becze
2019-10-01 20:54 ` Martin Becze [this message]
2019-10-01 20:54 ` [bug#37525] [PATCH v2 3/3] updated docs for import crate Martin Becze
2019-10-01 21:33 ` bug#37525: [PATCH v2 1/3] added recusive import functionality to the crate importer Ludovic Courtès
2019-10-01 21:52 ` [bug#37525] " Martin Becze
2019-10-02 14:28 ` Ludovic Courtès
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=20191001205458.20926-2-mjbecze@riseup.net \
--to=mjbecze@riseup.net \
--cc=37525@debbugs.gnu.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).