unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Nikita Karetnikov <nikita@karetnikov.org>
Cc: bug-guix@gnu.org
Subject: Re: [PATCH] guix-package: Add '--search'.
Date: Sat, 26 Jan 2013 22:43:56 +0100	[thread overview]
Message-ID: <871ud7d3hf.fsf@gnu.org> (raw)
In-Reply-To: <87622kuxu2.fsf_-_@karetnikov.org> (Nikita Karetnikov's message of "Sat, 26 Jan 2013 03:56:04 -0500")

Nikita Karetnikov <nikita@karetnikov.org> skribis:

>>    (if (or (and=> (package-synopsis package)
>>                   (compose matches? gettext))
>
> I came up with a different solution, which seems more readable.  What
> do you think?  (If you want, I'll use your version.)

[...]

> From 0083eff18eb584213f55974807d4e0e6e29d3c73 Mon Sep 17 00:00:00 2001
> From: Nikita Karetnikov <nikita@karetnikov.org>
> Date: Sat, 26 Jan 2013 08:36:31 +0000
> Subject: [PATCH] guix-package: Add '--search'.
>
> * guix-package.in (find-packages-by-description): New procedure.
>   (show-help, %options): Add '--search'.
>   (guix-package)[process-query]: Add support for '--search'.
> * doc/guix.texi (Invoking guix-package): Document it.
> * tests/guix-package.sh: Add tests.

[...]

> +@item --search=@var{regexp}
> +@itemx -s @var{regexp}
> +Search in the @emph{synopsis} and @emph{description} fields of the
> +available packages.  And list the ones that match @var{regexp}.

Rather:

  List the available packages whose synopsis or description matches
  @var{regexp}.

(The end-user shouldn’t have to think in terms of structure fields.)

> +  (delete-duplicates
> +   (sort
> +    (fold-packages (lambda (package result)
> +                     (if (any (lambda (f)
> +                                (false-if-exception
> +                                 (regexp-exec rx (gettext (f package)))))
> +                              (list package-synopsis package-description))
> +                         (cons package result)
> +                         result))
> +                   '())

I still prefer the solution that avoids ‘false-if-exception’, because
‘false-if-exception’ could hide real issues other than wrong-type-arg.

> +    # Search.
> +    echo "Testing 'search'..."
> +    if test "`guix-package -s "GNU Hello" | cut -f1`" = "hello";
> +    then echo "Test1: OK"; else echo "Test1: failed"; fi
> +
> +    if test "`guix-package -s "n0t4r341p4ck4g3"`" = "";
> +    then echo "Test2: OK"; else echo "Test2: failed"; fi

Please remove the ‘echo’ and ‘if’: it’s in a ‘set -x’ so everything gets
written to guix-package.log, and it’s in a ‘set -e’ so any non-zero exit
causes a test failure.

You can commit once those tiny issues are fixed.

Thank you!

Ludo’.

      reply	other threads:[~2013-01-26 21:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20  3:15 guix-package --search Nikita Karetnikov
2013-01-20 21:40 ` Nikita Karetnikov
2013-01-21 22:13   ` Ludovic Courtès
2013-01-23 15:33     ` Nikita Karetnikov
2013-01-24 21:14       ` Ludovic Courtès
2013-01-26  8:55         ` [PATCH] guix-package: Add '--search'. (was: guix-package --search) Nikita Karetnikov
2013-01-26 21:43           ` Ludovic Courtès [this message]

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=871ud7d3hf.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=bug-guix@gnu.org \
    --cc=nikita@karetnikov.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).