simplified pattern matching

main
Jesse Laprade 2020-07-16 17:03:53 -04:00
parent bad36d5229
commit b16a1a70bf
1 changed files with 2 additions and 4 deletions

View File

@ -275,16 +275,14 @@
(format " ~a ~a 2" program-name rm-command)))) (format " ~a ~a 2" program-name rm-command))))
(define (process-args vectorof-args) (define (process-args vectorof-args)
(define (args-ref number)
(vector-ref vectorof-args number))
(match vectorof-args (match vectorof-args
[(or (vector (== help-command-1)) [(or (vector (== help-command-1))
(vector (== help-command-2)) (vector (== help-command-2))
(vector (== help-command-3))) (help)] (vector (== help-command-3))) (help)]
[(vector (== ls-command)) (ls)] [(vector (== ls-command)) (ls)]
[(vector (== init-command)) (init)] [(vector (== init-command)) (init)]
[(vector (== add-command) _) (add (args-ref 1))] [(vector (== add-command) a) (add a)]
[(vector (== rm-command) _) (rm (args-ref 1))] [(vector (== rm-command) a) (rm a)]
[(vector _ _ _ ...) [(vector _ _ _ ...)
(displayln-messages-ref 'error-too-many-arguments)] (displayln-messages-ref 'error-too-many-arguments)]
[(vector _ _) [(vector _ _)