From a2a16bddc30e53cf7e33e02b187702fed03c724d Mon Sep 17 00:00:00 2001 From: m455 Date: Mon, 9 Apr 2018 20:03:12 -0400 Subject: [PATCH] can now accept LICENSE README.md rodo.rkt as an argument. todo: check for file when calling LICENSE README.md rodo.rkt --- rodo.rkt | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/rodo.rkt b/rodo.rkt index 8bf49ea..bc0263f 100755 --- a/rodo.rkt +++ b/rodo.rkt @@ -10,6 +10,10 @@ (define program-path "~/") (define program-file "todo-list") (define bullet "*") +(define remove-command "rm") +(define add-command "add") +(define list-command "ls") +(define initialize-command "init") (define (d-hash-ref hash-list key) (display (hash-ref hash-list key))) @@ -118,14 +122,14 @@ 'no '("no" "No" "n" "N"))) -(define (create-bullets) +(define (add-bullets) (lambda (lst) (string-append bullet " " lst))) -(define (show-list) +(define (show-list);; todo check for file like other functions (let ([path (expand-user-path @@ -140,8 +144,9 @@ #:line-mode 'linefeed)]) (display (string-join - (map (create-bullets) - todo-items) "\n"))))) + (map (add-bullets) + todo-items) "\n" + #:after-last "\n"))))) (define (add-item-to-file item) (let ([item (string-append item "\n")]) @@ -250,19 +255,24 @@ (let ([args-length (vector-length args)]) (cond + [(and + (equal? args-length 1) + (equal? (vector-member list-command args) 0)) + (show-list)] + [(and (equal? args-length 2) - (equal? (vector-member "add" args) 0)) + (equal? (vector-member add-command args) 0)) (add-item args)] [(and (equal? args-length 2) - (equal? (vector-member "remove" args) 0)) + (equal? (vector-member remove-command args) 0)) (remove-item args)] [(and (equal? args-length 1) - (equal? (vector-member "init" args) 0)) + (equal? (vector-member initialize-command args) 0)) (initialize)] [else