[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guix describe user experience improvement proposition

From: Ekaitz Zarraga
Subject: Re: guix describe user experience improvement proposition
Date: Tue, 12 May 2020 22:20:15 +0000

On Tuesday, May 12, 2020 10:13 PM, Ekaitz Zarraga <address@hidden> wrote:
> On Tuesday, May 12, 2020 9:44 PM, zimoun address@hidden wrote:
> > Usually, the way to add such information is '--list-formats', e.g.,
> > see "guix graph"with '--list-types' and '-list-backends'. I do not
> > know if it is an usually. ;-)
> But do you think it's interesting?
> Or is it just me?
> I like the `--list-types` approach. If it's interesting I would contribute 
> with a patch.


It would be something like this, tested and working.



diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm
index f13f221da9..69c6d8482f 100644
--- a/guix/scripts/describe.scm
+++ b/guix/scripts/describe.scm
@@ -42,13 +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"))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]