From a5975cedf27b3cb149629fe16846a6aeff17a96b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 27 Apr 2013 16:46:39 +0200 Subject: ui: Add `args-fold*' and use it. * guix/ui.scm (args-fold*): New procedure. * guix/scripts/build.scm, guix/scripts/download.scm, guix/scripts/gc.scm, guix/scripts/hash.scm, guix/scripts/import.scm, guix/scripts/package.scm, guix/scripts/pull.scm, guix/scripts/refresh.scm: Use `args-fold*' instead of `args-fold'. --- guix/ui.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'guix/ui.scm') 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 @@ (define-module (guix ui) #: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 @@ (define-module (guix ui) fill-paragraph string->recutils package->recutils + args-fold* run-guix-command program-name guix-warning-port @@ -370,6 +372,18 @@ (define (description->recutils str) (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) -- cgit v1.2.3