From patchwork Sat May 16 18:01:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ekaitz Zarraga X-Patchwork-Id: 22111 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D841127BBE3; Sat, 16 May 2020 19:02:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 47CBD27BBE1 for ; Sat, 16 May 2020 19:02:10 +0100 (BST) Received: from localhost ([::1]:40054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ja18T-0000qo-Qh for patchwork@mira.cbaines.net; Sat, 16 May 2020 14:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ja18N-0000pZ-4O for guix-patches@gnu.org; Sat, 16 May 2020 14:02:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ja18M-0003F3-M9 for guix-patches@gnu.org; Sat, 16 May 2020 14:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ja18M-0001qQ-JC for guix-patches@gnu.org; Sat, 16 May 2020 14:02:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41265] [PATCH] guix describe: Add '--list-formats' Resent-From: Ekaitz Zarraga Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 16 May 2020 18:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41265 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: "41265@debbugs.gnu.org" <41265@debbugs.gnu.org> Received: via spool by 41265-submit@debbugs.gnu.org id=B41265.15896520937053 (code B ref 41265); Sat, 16 May 2020 18:02:02 +0000 Received: (at 41265) by debbugs.gnu.org; 16 May 2020 18:01:33 +0000 Received: from localhost ([127.0.0.1]:41729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja17t-0001ph-Bf for submit@debbugs.gnu.org; Sat, 16 May 2020 14:01:33 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:51096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ja17r-0001pT-HQ for 41265@debbugs.gnu.org; Sat, 16 May 2020 14:01:32 -0400 Date: Sat, 16 May 2020 18:01:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech; s=protonmail; t=1589652084; bh=V6GKg74nP0ImSZubMUC/Pt3n8SFKALoTetvCpkbSGsE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=tgQxzlgoa45IHNXKC1yNogWVQk4Y54TjJQEta8ZuVXZO+jkHslvbhFv2nzpld1pm2 TeLFYHHogkNCfUNLwx57E+AjTKB0C9tn2pxZmHCvwa3dNqENG/7+UoY/swR3IP0e+M xASs3nIqPUu62IlBfWkP8KvuRnrEszL00ttpyt90= From: Ekaitz Zarraga Message-ID: In-Reply-To: <87r1vjpyu3.fsf@gnu.org> References: <87r1vjpyu3.fsf@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Ekaitz Zarraga Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Saturday, May 16, 2020 7:35 PM, Ludovic Courtès wrote: > Ekaitz Zarraga ekaitz@elenq.tech skribis: > > > > From 75f16431475fb692228f69be06baa635eb6fa5b7 Mon Sep 17 00:00:00 2001 > > > From: Ekaitz Zarraga ekaitz@elenq.tech > > > Date: Thu, 14 May 2020 17:25:03 +0200 > > > Subject: [PATCH] guix describe: Add '--list-formats' > > > > * guix/scripts/describe.scm (%available-formats): New variable. > > (list-fortmats): New procedure. > > > > ^^ > > > Typo. > > > (%options, show-help): Add --list-formats > > > > Could you also add the option to doc/guix.texi? > > TIA! > > Ludo’. There it goes, not sure if I added it right to the docs, never edited a texi before :) Cheers! From f7af79434eb702140ddadb321a4fcaaf197dbf45 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 16 May 2020 19:57:18 +0200 Subject: [PATCH] guix describe: Add '--list-formats' * guix/scripts/describe.scm (%available-formats): New variable. (list-formats): New procedure. (%options, show-help): Add --list-formats * doc/guix.texi: Add --list-formats --- doc/guix.texi | 3 +++ guix/scripts/describe.scm | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) -- 2.26.1 diff --git a/doc/guix.texi b/doc/guix.texi index d043852ac3..de2cbdf6e5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4475,6 +4475,9 @@ produce a list of channel specifications in JSON format; produce a list of channel specifications in Recutils format. @end table +@item --list-formats +Display available formats for @option{--format} option. + @item --profile=@var{profile} @itemx -p @var{profile} Display information about @var{profile}. diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index f13f221da9..7a2dbc453a 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2018 Oleg Pykhalov +;;; Copyright © 2020 Ekaitz Zarraga ;;; ;;; This file is part of GNU Guix. ;;; @@ -41,14 +42,26 @@ ;;; ;;; Command-line options. ;;; +(define %available-formats '("human" "channels" "json" "recutils")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) (define %options ;; Specifications of the command-line options. (list (option '(#\f "format") #t #f (lambda (opt name arg result) - (unless (member arg '("human" "channels" "json" "recutils")) + (unless (member arg %available-formats) (leave (G_ "~a: unsupported output format~%") arg)) (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))) (option '(#\p "profile") #t #f (lambda (opt name arg result) (alist-cons 'profile (canonicalize-profile arg) @@ -70,6 +83,8 @@ Display information about the channels currently in use.\n")) (display (G_ " -f, --format=FORMAT display information in the given FORMAT")) + (display (G_ " + --list-formats display available formats")) (display (G_ " -p, --profile=PROFILE display information about PROFILE")) (newline)