]> git.jsancho.org Git - guile-click.git/blobdiff - click.scm
Improve reading for default values and prompt
[guile-click.git] / click.scm
index afeb2f914fa1145ad0573108a18f37f9ae84b0f8..aa804306de2fd2ec6d2ebd2a5864e28ef83fd78f 100644 (file)
--- a/click.scm
+++ b/click.scm
   #:use-module (click util)
   #:export (command))
 
-(define (get-options-value options option-spec)
-  (cond ((null? option-spec)
-         '())
-        (else
-         (let* ((option (car option-spec))
-                (option-name (car option))
-                (default (option-default-value option)))
-           (cons (cons option-name (option-ref options option-name default))
-                 (get-options-value options (cdr option-spec)))))))
 
 (define (command option-spec procedure)
   (lambda (args)
     (with-fluids ((%program-name (car args)))
       (let* ((click-option-spec (append option-spec (list HELP_OPTION)))
-             (options (getopt-long args
-                                   (getopt-long-option-spec click-option-spec))))
-        (if (option-ref options 'help #f)
+             (values (getopt-long args
+                                  (getopt-long-option-spec click-option-spec))))
+        (if (option-ref values 'help #f)
             (display-help procedure click-option-spec)
-            (apply procedure (map cdr (get-options-value options option-spec))))))))
+            (apply procedure (map cdr (get-values option-spec values))))))))