moved get-argument-value-or-default to argparse module, counter fix
This commit is contained in:
parent
5c20c37c15
commit
36d1b9fac5
|
@ -1,7 +1,8 @@
|
|||
(module eliana-argparse
|
||||
(export get-switch-value
|
||||
value-next?
|
||||
argument-present?)
|
||||
argument-present?
|
||||
get-argument-value-or-default)
|
||||
|
||||
(import (chicken base)
|
||||
(chicken process-context)
|
||||
|
@ -41,4 +42,9 @@
|
|||
(argument-present? switch)
|
||||
(value-next? switch))
|
||||
(cadr (member switch ARGS))
|
||||
(error "Argument malformed or not present after" switch))))
|
||||
(error "Argument malformed or not present after" switch)))
|
||||
|
||||
(define (get-argument-value-or-default option default)
|
||||
(if (argument-present? option)
|
||||
(get-switch-value option)
|
||||
default)))
|
||||
|
|
21
eliana.scm
21
eliana.scm
|
@ -43,26 +43,23 @@
|
|||
"Z8P4ck4k2k3pE8qy8Asd"
|
||||
"...")))
|
||||
|
||||
(define (get-argument-value-or-default option default)
|
||||
(if (argp:argument-present? option)
|
||||
(argp:get-switch-value option)
|
||||
default))
|
||||
|
||||
(define (main)
|
||||
(when (argp:argument-present? "-h")
|
||||
(print-help-message)
|
||||
(exit))
|
||||
(let* ((data-set (get-argument-value-or-default "-d" DEFAULT-DATA-SET))
|
||||
(key-length (string->number (get-argument-value-or-default "-l" DEFAULT-KEY-LENGTH)))
|
||||
(let* ((data-set (argp:get-argument-value-or-default "-d" DEFAULT-DATA-SET))
|
||||
(key-length (string->number (argp:get-argument-value-or-default "-l" DEFAULT-KEY-LENGTH)))
|
||||
(change-entire-key? (if (argp:argument-present? "-w") #t #f))
|
||||
(key-container (eli:make-key-container key-length))
|
||||
(prefix (get-argument-value-or-default "-b" #f))
|
||||
(postfix (get-argument-value-or-default "-a" #f))
|
||||
(seed (get-argument-value-or-default "-s" (number->string (current-milliseconds))))
|
||||
(max-count (get-argument-value-or-default "-c" #f)))
|
||||
(prefix (argp:get-argument-value-or-default "-b" #f))
|
||||
(postfix (argp:get-argument-value-or-default "-a" #f))
|
||||
(seed (argp:get-argument-value-or-default "-s" (number->string (current-milliseconds))))
|
||||
(max-count (argp:get-argument-value-or-default "-c" #f)))
|
||||
(eli:eliana-initialize! seed)
|
||||
(let loop ((count 1)
|
||||
(max-count (when max-count (string->number max-count))))
|
||||
(max-count (if max-count
|
||||
(string->number max-count)
|
||||
max-count)))
|
||||
(eli:change-key! key-container data-set change-entire-key?)
|
||||
(eli:print-key key-container #:prefix prefix #:postfix postfix)
|
||||
(cond (max-count
|
||||
|
|
Loading…
Reference in New Issue