(cond ((null? option-spec)
'())
(else
- (let ((option (caar option-spec)))
- (cons (cons option (option-ref options option #f))
+ (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)
(define-module (click util)
+ #:use-module (ice-9 readline)
#:use-module (click constant)
#:export (getopt-long-option-spec
+ option-default-value
option-property
program-name
%program-name))
(if property
(cadr property)
default)))
+
+(define* (option-default-value option #:optional (no-prompt #f))
+ "Get default value for option, asking user if prompt property is set"
+ (let ((default (option-property option 'default)))
+ (if (not default)
+ (let ((prompt (option-property option 'prompt)))
+ (if prompt
+ (readline (format #f "~a: " prompt))
+ default))
+ default)))
"Simple program that greets NAME for a total of COUNT times."
(let loop ((times count))
(cond ((> times 0)
- (format #t "Hello ~a!" name)
+ (format #t "Hello ~a!~%" name)
(loop (- times 1))))))))
(hello (command-line))