unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Cyril Roelandt <tipecaml@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] guix package: add a "show" option.
Date: Tue, 15 Jul 2014 23:23:15 +0200	[thread overview]
Message-ID: <87r41mjozg.fsf@gnu.org> (raw)
In-Reply-To: <1405277641-2891-1-git-send-email-tipecaml@gmail.com> (Cyril Roelandt's message of "Sun, 13 Jul 2014 20:54:01 +0200")

Cyril Roelandt <tipecaml@gmail.com> skribis:

> * guix/packages.scm (package-direct-inputs): New procedure.
> * guix/scripts/package.scm: Add a "show" option.
> * tests/guix-package.sh: Add a test for the "show" option.

Given that there is popular demand ;-), here’s a better review.

> +(define (package-direct-inputs package)
> +  (sort (append (package-inputs package)
> +                (package-native-inputs package)
> +                (package-propagated-inputs package))
> +        (lambda (p1 p2)
> +          (string<? (car p1) (car p2)))))

Please add a docstring and at least one test in tests/packages.scm.

However, please remove ‘sort’ from here.  The labels we use in package
inputs don’t have any special meaning, so there’s no reason to sort
things here, and they’ll probably vanish once we’ve fully integrated
gexps.

> +  (display (_ "
> +  --show=PACKAGE         show details about PACKAGE"))

Please also add it to guix.texi, mentioning that the output is in
recutils format.

> +        (('show-package requested-name)
> +         (let* ((available (fold-packages
> +                            (lambda (p r)
> +                              (let ((name (package-name p))
> +                                    (full-name (package-full-name p)))
> +                                (if (or (string=? requested-name name)
> +                                        (string=? requested-name full-name))
> +                                    (cons p r)
> +                                    r)))
> +                            '())))

Use ‘specification->package+output’ (and ignore the second return value)
instead of ‘fold-packages’.

> +           (leave-on-EPIPE
> +            (for-each (lambda (p)
> +                        (format #t "Package: ~a\n\
> +Version: ~a\n\
> +Description: ~a\n\
> +Depends: ~a\n\
> +Homepage: ~a\n\
> +License: ~a\n~%"
> +                                (package-name p)
> +                                (package-version p)
> +                                (package-description p)
> +                                (string-join (map car (package-direct-inputs p)) ", ")
> +                                (package-home-page p)
> +                                (license-name (package-license p))))

Use ‘package->recutils’ instead of this.

In a separate patch, you can augment it to add the ‘depends’ field.

> +                      (sort available
> +                            (lambda (p1 p2)
> +                              (version>? (package-version p2) (package-version p1))))))

Sort by ‘package-full-name’ instead of ‘package-version’.

Thoughts?

Thanks!

Ludo’.

  parent reply	other threads:[~2014-07-15 21:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 18:54 [PATCH] guix package: add a "show" option Cyril Roelandt
2014-07-13 21:32 ` Ludovic Courtès
2014-07-14  8:41   ` Andreas Enge
2014-07-14  8:47     ` Alex Sassmannshausen
2014-07-14  9:03       ` John Darrington
2014-07-15 21:23 ` Ludovic Courtès [this message]
2014-07-17  0:54   ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
2014-07-17  0:54     ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
2014-07-17 23:30       ` Ludovic Courtès
2014-07-17 23:26     ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
2014-07-20 23:48       ` [PATCH v3 " Cyril Roelandt
2014-07-21 15:51         ` Ludovic Courtès
2014-07-20 23:49       ` [PATCH v2 " Cyril Roelandt
2014-07-21 15:53         ` 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=87r41mjozg.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=tipecaml@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).