Lazily plays media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

35 lines
1.1 KiB

#lang racket
;; guard procedure for the command type
(define/contract (valid? identifier argument-strings name)
(-> string? (or/c string? (listof string?)) (or/c string? symbol?) (values string? (listof string?)))
(values identifier (list argument-strings)))
;; command type
(struct command (identifier))
(struct add-resources command (resources))
(struct remove-command command (resources))
(struct add-commands command (commands))
(struct chdir command (directory))
(struct modify command (command-name new-content))
(struct commands (add-resources
remove-command
add-commands
chdir
modify))
;; parses a command to be sent to the player thread
(define (parse-command cmd)
(match cmd
[(? string?)
(match (regexp-split #px"\\s" cmd)
[(list-rest "cmds" xs) (add-commands "cmds" xs)]
[(list-rest "add" xs) (add-resources "add" (list (string-join xs "")))]
[(list-rest "chdir" xs) (chdir "chdir" xs)]
[(list-rest "rm" xs) (remove-command "rem" xs)]
[_ (command #f)])]
[_ (command #f)]))
(provide (all-defined-out))