summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index f8826cd488..7a37ad2cee 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -29,6 +29,7 @@
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-37)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:export (_
@@ -46,6 +47,7 @@
fill-paragraph
string->recutils
package->recutils
+ args-fold*
run-guix-command
program-name
guix-warning-port
@@ -370,6 +372,18 @@ WIDTH columns."
(and=> (package-description p) description->recutils))
(newline port))
+(define (args-fold* options unrecognized-option-proc operand-proc . seeds)
+ "A wrapper on top of `args-fold' that does proper user-facing error
+reporting."
+ (catch 'misc-error
+ (lambda ()
+ (apply args-fold options unrecognized-option-proc
+ operand-proc seeds))
+ (lambda (key proc msg args . rest)
+ ;; XXX: MSG is not i18n'd.
+ (leave (_ "invalid argument: ~a~%")
+ (apply format #f msg args)))))
+
(define (show-guix-usage)
;; TODO: Dynamically generate a summary of available commands.
(format (current-error-port)