diff --git a/rodo.rkt b/rodo.rkt index 1b4e35a..3bcb5d3 100755 --- a/rodo.rkt +++ b/rodo.rkt @@ -1,7 +1,7 @@ #! /usr/bin/env racket #lang racket/base -(define (display-hash hash-list key) +(define (displayln-hash-ref hash-list key) (displayln (hash-ref hash-list key))) (define messages (hash @@ -21,26 +21,27 @@ (define (open/create-file path) (let ([path (expand-user-path path)]) - (open-output-file path + (let ([opened-file (open-output-file path #:mode 'text - #:exists 'can-update))) + #:exists 'can-update)]) + (close-output-port opened-file)))) (define (prompt-user prompt-message) - (display-hash messages prompt-message) + (displayln-hash-ref messages prompt-message) (let ([user-input (read-line)]) (cond [(member user-input (hash-ref y/n 'yes)) - (display-hash messages 'creating-file) + (displayln-hash-ref messages 'creating-file) (open/create-file "~/.rodo")] [(member user-input (hash-ref y/n 'no)) - (display-hash messages 'terminating)] + (displayln-hash-ref messages 'terminating)] [else - (display-hash messages 'choose-y/n) + (displayln-hash-ref messages 'choose-y/n) (prompt-user 'file-not-found)]))) (define (todo-list-exist?) (if (file-exists? (expand-user-path "~/.rodo")) - (display-hash messages 'file-exists) + (displayln-hash-ref messages 'file-exists) (prompt-user 'file-not-found))) (todo-list-exist?)