reformatted args.rkt

main
m455 2018-10-10 13:59:48 -04:00
parent d56570dcc2
commit 38e14b967e
1 changed files with 36 additions and 32 deletions

View File

@ -10,35 +10,39 @@
(provide (all-defined-out)) (provide (all-defined-out))
(define (check-args args) (define (check-args args)
(let (let([args-length (vector-length args)])
([args-length (vector-length args)]) (cond [(equal? args-length 0)
(cond (util:display-hash-ref messages:messages 'show-usage)]
[(equal? args-length 0)
(util:display-hash-ref messages:messages 'show-usage)] [(and
[(and (equal? args-length 1)
(equal? args-length 1) (equal? (vector:vector-member config:list-command args) 0))
(equal? (vector:vector-member config:list-command args) 0)) (util:show-list)]
(util:show-list)]
[(and [(and
(equal? args-length 2) (equal? args-length 2)
(equal? (vector-ref args 0) config:add-command)) (equal? (vector-ref args 0) config:add-command))
(util:add-item args)] (util:add-item args)]
[(and
(equal? args-length 2) [(and
(equal? (vector:vector-member config:remove-command args) 0) (equal? args-length 2)
(not (equal? (vector:vector-member "0" args) 1)) (equal? (vector:vector-member config:remove-command args) 0)
(vector:vector-member (not (equal? (vector:vector-member "0" args) 1))
(vector-ref args 1) (vector:vector-member
(list->vector (vector-ref args 1)
(map number->string (list:rest (list:range (length (util:file->string-list config:path)))))))) (list->vector
(util:remove-item args)] (map number->string (list:rest (list:range (length (util:file->string-list config:path))))))))
[(and (util:remove-item args)]
(equal? args-length 1)
(equal? (vector:vector-member config:initialize-command args) 0)) [(and
(init:initialize)] (equal? args-length 1)
[(and (equal? (vector:vector-member config:initialize-command args) 0))
(equal? args-length 1) (init:initialize)]
(member (vector-ref args 0) config:help-command))
(util:display-hash-ref messages:messages 'show-help)] [(and
[else (equal? args-length 1)
(util:display-hash-ref messages:messages 'show-usage)]))) (member (vector-ref args 0) config:help-command))
(util:display-hash-ref messages:messages 'show-help)]
[else
(util:display-hash-ref messages:messages 'show-usage)])))