2018-04-12 18:25:19 +00:00
|
|
|
#lang racket/base
|
|
|
|
|
|
|
|
(require racket/vector
|
2018-04-21 13:11:02 +00:00
|
|
|
racket/list
|
2018-04-12 18:25:19 +00:00
|
|
|
"config.rkt"
|
|
|
|
"init.rkt"
|
2018-04-12 18:37:01 +00:00
|
|
|
"util.rkt"
|
2018-04-12 18:25:19 +00:00
|
|
|
"messages.rkt")
|
|
|
|
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
|
|
|
(define (check-args args)
|
|
|
|
(let
|
|
|
|
([args-length (vector-length args)])
|
|
|
|
(cond
|
2018-04-18 02:58:33 +00:00
|
|
|
[(equal? args-length 0)
|
|
|
|
(d-hash-ref messages 'show-usage)]
|
|
|
|
|
2018-04-12 18:25:19 +00:00
|
|
|
[(and
|
|
|
|
(equal? args-length 1)
|
|
|
|
(equal? (vector-member list-command args) 0))
|
|
|
|
(show-list)]
|
|
|
|
|
|
|
|
[(and
|
2018-04-18 02:58:33 +00:00
|
|
|
(equal? args-length 2)
|
|
|
|
(equal? (vector-ref args 0) add-command))
|
|
|
|
(add-item args)]
|
2018-04-12 18:25:19 +00:00
|
|
|
|
|
|
|
[(and
|
|
|
|
(equal? args-length 2)
|
2018-04-21 13:11:02 +00:00
|
|
|
(equal? (vector-member remove-command args) 0)
|
|
|
|
(not (equal? (vector-member "0" args) 1))
|
2018-04-21 13:21:10 +00:00
|
|
|
(vector-member (vector-ref args 1) (list->vector (map number->string (rest (range (length (file->string-list path))))))))
|
2018-04-12 18:25:19 +00:00
|
|
|
(remove-item args)]
|
|
|
|
|
|
|
|
[(and
|
|
|
|
(equal? args-length 1)
|
|
|
|
(equal? (vector-member initialize-command args) 0))
|
|
|
|
(initialize)]
|
|
|
|
|
2018-04-13 05:02:48 +00:00
|
|
|
[(and
|
|
|
|
(equal? args-length 1)
|
|
|
|
(member (vector-ref args 0) help-command))
|
|
|
|
(d-hash-ref messages 'show-help)]
|
|
|
|
|
2018-04-12 18:25:19 +00:00
|
|
|
[else
|
|
|
|
(d-hash-ref messages 'show-usage)])))
|