diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-04-27 16:46:39 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-04-27 16:46:39 +0200 |
commit | a5975cedf27b3cb149629fe16846a6aeff17a96b (patch) | |
tree | 7c1be73feb1ebd8605e4fad462bdb3d9feec1959 /guix/ui.scm | |
parent | 14e2afa74ba5653f263ecfc0b89c704bed237bd5 (diff) | |
download | gnu-guix-a5975cedf27b3cb149629fe16846a6aeff17a96b.tar gnu-guix-a5975cedf27b3cb149629fe16846a6aeff17a96b.tar.gz |
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'.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 14 |
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) |