18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
(module mtargs
(
arg-hash
get-arg
get-arg-number
get-arg-from
get-args
usage
print-args
any-defined?
)
(import scheme) ;; gives us cond-expand in chicken-4
|
>
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
(module mtargs
(
arg-hash
get-arg
get-arg-number
get-arg-from
remove-arg-from-ht
get-args
usage
print-args
any-defined?
)
(import scheme) ;; gives us cond-expand in chicken-4
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
;; (define any any-defined?)
(define (get-arg-from ht arg . default)
(if (null? default)
(hash-table-ref/default ht arg #f)
(hash-table-ref/default ht arg (car default))))
(define (get-args args params switches arg-hash num-needed)
(let* ((numtargs (length args))
(adj-num-needed (if num-needed (+ num-needed 2) #f)))
(if (< numtargs (if adj-num-needed adj-num-needed 2))
(if (>= num-needed 1)
(usage "No arguments provided")
|
>
>
>
>
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
;; (define any any-defined?)
(define (get-arg-from ht arg . default)
(if (null? default)
(hash-table-ref/default ht arg #f)
(hash-table-ref/default ht arg (car default))))
(define (remove-arg-from-ht arg)
(hash-table-delete! arg-hash arg)
)
(define (get-args args params switches arg-hash num-needed)
(let* ((numtargs (length args))
(adj-num-needed (if num-needed (+ num-needed 2) #f)))
(if (< numtargs (if adj-num-needed adj-num-needed 2))
(if (>= num-needed 1)
(usage "No arguments provided")
|