leque #7611(2008/09/10 06:55 GMT) [ Scheme ] Rating0/0=0.00
args-fold 版。ロングオプション対応。起動例のすべてのパターンを受け付けます(-s を -d にした場合)。
see: SRFI 37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
(use srfi-37) (use gauche.sequence) (define (main args) (receive (debug output quiet rargv) (args-fold (cdr args) (list (option '(#\d "debug") #t #f (lambda (option name arg debug output quiet argv) (values (string->number arg) output quiet argv))) (option '(#\o "output") #f #f (lambda (option name arg debug output quiet argv) (values debug #t quiet argv))) (option '(#\q "quiet") #f #f (lambda (option name arg debug output quiet argv) (values debug output #t argv))) ) (lambda (option name arg . _) (error "Unrecognized option: " name)) (lambda (op debug output quiet argv) (values debug output quiet (cons op argv))) 0 #f #f '()) (cond ((not output) (format (current-error-port) "output option is not supplied.~%")) ((not (memv debug '(0 1 2))) (format (current-error-port) "debug option's value must be 0, 1, or 2: ~A~%" debug)) ((null? rargv) (format (current-error-port) "no arguments are supplied.~%")) (else (format #t "[options]~%o(output): ON~%q(quiet): ~A~%d(debug): ~A~%~%" (if quiet 'ON 'OFF) debug) (format #t "[parameters]~%# of pamameters: ~A~%" (length rargv)) (for-each-with-index (lambda (i x) (format #t "~A: ~A~%" (+ i 1) x)) (reverse rargv)) (exit 0))) 1))
Rating0/0=0.00-0+
[ reply ]
leque
#7611()
[
Scheme
]
Rating0/0=0.00
args-fold 版。ロングオプション対応。起動例のすべてのパターンを受け付けます(-s を -d にした場合)。
see: SRFI 37
Rating0/0=0.00-0+
[ reply ]