slowly cleaning things up
parent
457af43ca2
commit
3809c451bd
20
args.rkt
20
args.rkt
|
@ -9,34 +9,40 @@
|
||||||
(provide (all-defined-out))
|
(provide (all-defined-out))
|
||||||
|
|
||||||
(define (check-args args)
|
(define (check-args args)
|
||||||
(let ([args-length (length args)])
|
(let ([args-length (length args)]
|
||||||
|
[is-member? (lambda (command)
|
||||||
|
(member (list-ref args 0) command))])
|
||||||
(cond
|
(cond
|
||||||
[(equal? args-length 0)
|
[(equal? args-length 0)
|
||||||
(utils:display-messages '(show-usage))]
|
(utils:display-messages '(show-usage))]
|
||||||
|
|
||||||
;; help-command
|
;; help-command
|
||||||
[(and (equal? args-length 1)
|
[(and (equal? args-length 1)
|
||||||
(member (list-ref args 0) config:help-commands))
|
(is-member? config:help-commands))
|
||||||
(utils:display-messages '(show-help))]
|
(utils:display-messages '(show-help))]
|
||||||
|
|
||||||
;; initialize-command
|
;; initialize-command
|
||||||
[(and (equal? args-length 1)
|
[(and (equal? args-length 1)
|
||||||
(member (list-ref args 0) config:initialize-commands))
|
(is-member? config:initialize-commands))
|
||||||
(init:check-initialize-conditions)]
|
(init:check-initialize-conditions)]
|
||||||
|
|
||||||
;; add-command
|
;; add-command
|
||||||
[(and (or (equal? args-length 2) (>= args-length 2))
|
[(and (>= args-length 2)
|
||||||
(member (list-ref args 0) config:add-commands))
|
(is-member? config:add-commands))
|
||||||
(utils:check-add-conditions args)]
|
(utils:check-add-conditions args)]
|
||||||
|
|
||||||
;; list-command
|
;; list-command
|
||||||
[(and (equal? args-length 1)
|
[(and (equal? args-length 1)
|
||||||
(member (list-ref args 0) config:list-commands))
|
(is-member? config:list-commands))
|
||||||
(utils:check-list-conditions)]
|
(utils:check-list-conditions)]
|
||||||
|
|
||||||
;; remove-command
|
;; remove-command
|
||||||
[(and (equal? args-length 2)
|
[(and (equal? args-length 2)
|
||||||
(member (list-ref args 0) config:remove-commands)
|
(is-member? config:remove-commands)
|
||||||
|
;; possibly replace this with something that checks
|
||||||
|
;; the length, the creates a range with that, starting
|
||||||
|
;; from zero, and checks to see if the user input
|
||||||
|
;; is a member of that list
|
||||||
(real? (string->number (list-ref args 1)))
|
(real? (string->number (list-ref args 1)))
|
||||||
(or (positive? (string->number (list-ref args 1)))
|
(or (positive? (string->number (list-ref args 1)))
|
||||||
(zero? (string->number (list-ref args 1)))))
|
(zero? (string->number (list-ref args 1)))))
|
||||||
|
|
5
rodo.rkt
5
rodo.rkt
|
@ -3,6 +3,7 @@
|
||||||
(require (prefix-in args: "args.rkt"))
|
(require (prefix-in args: "args.rkt"))
|
||||||
|
|
||||||
(define (main args)
|
(define (main args)
|
||||||
(args:check-args args))
|
(let ([args-converted (vector->list args)])
|
||||||
|
(args:check-args args-converted)))
|
||||||
|
|
||||||
(main (vector->list (current-command-line-arguments)))
|
(main (current-command-line-arguments))
|
||||||
|
|
Loading…
Reference in New Issue