rodo/rodo.rkt

37 lines
1.2 KiB
Racket
Raw Normal View History

2018-03-12 14:02:54 +00:00
#! /usr/bin/env racket
#lang racket/base
2018-03-13 02:19:16 +00:00
(define (display-hash hash-list key)
(displayln (hash-ref hash-list key)))
2018-03-12 14:02:54 +00:00
(define message (hash
2018-03-13 16:39:10 +00:00
'incorrect-usage-msg "For usage type `rodo -h` or `rodo --help`"
'file-not-found "rodo has not been setup in your home directory\nWould you like to set it up now? [y/n]"
2018-03-12 14:02:54 +00:00
'file-exists ".rodo file exists"
'item-added "Item added"
2018-03-13 16:39:10 +00:00
'item-removed "Item removed"
2018-03-12 14:02:54 +00:00
'initializing "Initializing rodo in your home directory"))
2018-03-13 16:39:10 +00:00
(define y-n (hash
'yes '("yes" "Yes" "y" "Y")
'no '("no" "No" "n" "N")))
2018-03-13 02:19:16 +00:00
; just figuring out stuff here
(define (prompt-user prompt-message)
(display-hash message prompt-message)
(let ([user-input (read-line)])
(cond
2018-03-13 16:39:10 +00:00
[(member user-input (hash-ref y-n 'yes))
2018-03-13 02:19:16 +00:00
(displayln "You chose yes")]
2018-03-13 16:47:05 +00:00
[(member user-input (hash-ref y-n 'no))
(displayln "You chose no")]
2018-03-13 02:19:16 +00:00
[else
(displayln "you chose something else")])))
2018-03-12 14:02:54 +00:00
(define (todo-list-exist?)
(if (file-exists? (expand-user-path "~/.rodo"))
2018-03-13 02:19:16 +00:00
(display-hash message 'file-exists)
(prompt-user 'file-not-found)))
2018-03-12 14:02:54 +00:00
(todo-list-exist?)