diff --git a/messages.rkt b/messages.rkt index cfc1f78..319dbae 100644 --- a/messages.rkt +++ b/messages.rkt @@ -6,38 +6,38 @@ (define messages (hash - 'show-help - (string-append - config:initialize-command ":\n" - "initialize a file in " - config:program-path - config:program-directory - config:program-file - "\n" - "Example: " - "rodo init\n\n" + 'show-help (string-append + config:initialize-command + " - " + "initialize a file in " + config:program-path + config:program-directory + config:program-file + "\n" + "Example: " + "rodo init\n\n" - config:list-command ":\n" - "lists items on the list" - "\n" - "Example: " - "rodo ls\n\n" + config:list-command ":\n" + "lists items on the list" + "\n" + "Example: " + "rodo ls\n\n" - config:add-command ":\n" - "adds an item to the list" - "\n" - "Example: " - "rodo add bread\n\n" - "Note: For multi-word items you will need to\n" - "surround your item in double quotes as so:\n" - "rodo add \"go to the bank\"\n\n" + config:add-command ":\n" + "adds an item to the list" + "\n" + "Example: " + "rodo add bread\n\n" + "Note: For multi-word items you will need to\n" + "surround your item in double quotes as so:\n" + "rodo add \"go to the bank\"\n\n" - config:remove-command ":\n" - "removes an item from the list\n" - "Example: " - "rodo rm 1\n\n" - "Note: You may have to run `rodo ls` to see which\n" - "number corresponds to which item to remove it.\n") + config:remove-command ":\n" + "removes an item from the list\n" + "Example: " + "rodo rm 1\n\n" + "Note: You may have to run `rodo ls` to see which\n" + "number corresponds to which item to remove it.\n") 'empty-todo-list "> There is nothing in your list \n" diff --git a/util.rkt b/util.rkt index 829a4a4..37a6be4 100644 --- a/util.rkt +++ b/util.rkt @@ -33,13 +33,10 @@ (define (display-hash-ref hash-list key) (display (hash-ref hash-list key))) -(define (d-vector-ref args key) - (display (vector-ref args key))) - (define (file->string-list config:path-to-file) - (let ([todo-list (file:file->lines config:path-to-file - #:mode 'text - #:line-mode 'any)]) + (let ([todo-list (file:file->lines config:path-to-file + #:mode 'text + #:line-mode 'any)]) todo-list)) (define (list-empty? lst) @@ -53,9 +50,11 @@ (string-append "\"" args "\""))) (define (prefix-with-number lst) - (map string-append - (map number->string (list:rest (list:range (length lst)))) - (list:rest lst))) + (map string-append + (map number->string + (list:rest + (list:range (length lst)))) + (list:rest lst))) (define (prefix-with-period lst) (string-append ". " lst)) @@ -63,8 +62,8 @@ (define (prettify-list) (display (string:string-join (prefix-with-number (map prefix-with-period (file->string-list config:path))) - "\n" - #:after-last "\n"))) + "\n" + #:after-last "\n"))) (define (append-to-end args lst) (reverse (cons args (reverse (file->string-list lst))))) @@ -93,7 +92,7 @@ (define (add-item-to-file args) (let ([new-list (append-to-end args config:path)]) - (file:display-to-file + (file:display-to-file (string:string-join new-list "\n" #:after-last "\n") config:path #:mode 'text @@ -111,10 +110,10 @@ (define (remove-item-from-file args) (let ([removed-item (get-removed-item (file->string-list config:path) args)] - [new-list (remove - (list-ref (file->string-list config:path) (string->number args)) + [new-list (remove + (list-ref (file->string-list config:path) (string->number args)) (file->string-list config:path))]) - (file:display-to-file + (file:display-to-file (string:string-join new-list "\n" #:after-last "\n") config:path #:mode 'text @@ -124,11 +123,11 @@ (define (remove-item args) (cond [(list-empty? config:path) (display-hash-ref messages:messages 'empty-todo-list)] - [(and + [(and (check-for-folder) (check-for-file)) - (remove-item-from-file (vector-ref args 1))] - [(and (not (check-for-folder)) (not (check-for-file))) - (begin - (display-hash-ref messages:messages 'file-not-found) - (display-hash-ref messages:messages 'try-init))])) + (remove-item-from-file (vector-ref args 1))] + [(and (not (check-for-folder)) (not (check-for-file))) + (begin + (display-hash-ref messages:messages 'file-not-found) + (display-hash-ref messages:messages 'try-init))]))