can now display what was added to a list, even though nothing was haha
parent
1c26fa59fc
commit
ba21738540
52
rodo.rkt
52
rodo.rkt
|
@ -7,21 +7,26 @@
|
||||||
(define program-directory ".rodo/")
|
(define program-directory ".rodo/")
|
||||||
(define program-path "~/")
|
(define program-path "~/")
|
||||||
|
|
||||||
(define (d-hash-ref key)
|
(define (d-hash-ref hash-list key)
|
||||||
(displayln (hash-ref messages key)))
|
(display (hash-ref messages key)))
|
||||||
|
|
||||||
|
(define (d-vector-ref args key)
|
||||||
|
(display (vector-ref args key)))
|
||||||
|
|
||||||
(define messages
|
(define messages
|
||||||
(hash
|
(hash
|
||||||
'incorrect-usage (string-append "> For usage type `" program-name " -h` or `" program-name " --help`")
|
'incorrect-usage (string-append "> For usage type `" program-name " -h` or `" program-name " --help`\n")
|
||||||
'creating (string-append "> Creating a " program-directory " folder in " program-path "...")
|
'creating (string-append "> Creating a " program-directory " folder in " program-path "...\n")
|
||||||
'creation-error (string-append "> Error: Could not create " program-directory " in " program-path ".\n> This may be due to directory permissions")
|
'creation-error (string-append "> Error: Could not create " program-directory " in " program-path ".\n> This may be due to directory permissions\n")
|
||||||
'already-exists (string-append "> " program-directory " folder already exists in " program-path)
|
'already-exists (string-append "> " program-directory " folder already exists in " program-path "\n")
|
||||||
'successfully-created (string-append "> " program-path program-directory " has been successfully created")
|
'successfully-created (string-append "> " program-path program-directory " has been successfully created\n")
|
||||||
'not-found (string-append "> " program-directory " has not been setup in " program-path "\n> Would you like to set it up now? [y/n]")
|
'not-found (string-append "> " program-directory " has not been setup in " program-path "\n> Would you like to set it up now? [y/n]\n")
|
||||||
'item-added "> Added item to list"
|
'item-added-prefix "> Added "
|
||||||
'item-removed "> Added item to list"
|
'item-added-suffix " to list\n"
|
||||||
'terminating (string-append "> Exiting " program-name "...")
|
'item-removed-prefix "> Removed "
|
||||||
'choose-y/n "> Error: Please choose y or n"))
|
'item-removed-suffix "from list\n"
|
||||||
|
'terminating (string-append "> Exiting " program-name "...\n")
|
||||||
|
'choose-y/n "> Error: Please choose y or n\n"))
|
||||||
|
|
||||||
;; some possible user-input related "mistakes" that will be accepted for input
|
;; some possible user-input related "mistakes" that will be accepted for input
|
||||||
(define y/n
|
(define y/n
|
||||||
|
@ -44,18 +49,18 @@
|
||||||
|
|
||||||
;; prompt user for file initial file creation
|
;; prompt user for file initial file creation
|
||||||
(define (prompt-user chosen-message)
|
(define (prompt-user chosen-message)
|
||||||
(d-hash-ref chosen-message)
|
(d-hash-ref messages chosen-message)
|
||||||
(display "> ")
|
(display "> ")
|
||||||
(let ([user-input (read-line)])
|
(let ([user-input (read-line)])
|
||||||
(cond
|
(cond
|
||||||
[(member user-input (hash-ref y/n 'yes))
|
[(member user-input (hash-ref y/n 'yes))
|
||||||
(d-hash-ref 'creating)
|
(d-hash-ref messages 'creating)
|
||||||
(create-folder)
|
(create-folder)
|
||||||
(if (check-for-folder)
|
(if (check-for-folder)
|
||||||
(d-hash-ref 'successfully-created)
|
(d-hash-ref messages 'successfully-created)
|
||||||
(d-hash-ref 'creation-error))]
|
(d-hash-ref messages 'creation-error))]
|
||||||
[(member user-input (hash-ref y/n 'no))
|
[(member user-input (hash-ref y/n 'no))
|
||||||
(d-hash-ref 'terminating)]
|
(d-hash-ref messages 'terminating)]
|
||||||
[else
|
[else
|
||||||
(prompt-user 'choose-y/n)])))
|
(prompt-user 'choose-y/n)])))
|
||||||
|
|
||||||
|
@ -63,19 +68,22 @@
|
||||||
(let ([args-length (vector-length args)])
|
(let ([args-length (vector-length args)])
|
||||||
(cond
|
(cond
|
||||||
[(or (equal? args-length 0) (> args-length 2))
|
[(or (equal? args-length 0) (> args-length 2))
|
||||||
(d-hash-ref 'incorrect-usage)]
|
(d-hash-ref messages 'incorrect-usage)]
|
||||||
[(and (equal? args-length 2) (equal? (vector-member "add" args) 0))
|
[(and (equal? args-length 2) (equal? (vector-member "add" args) 0))
|
||||||
(d-hash-ref 'item-added)]
|
;; (d-hash-ref messages 'item-added-prefix) (vector-ref args 1)]
|
||||||
|
(d-hash-ref messages 'item-added-prefix)
|
||||||
|
(d-vector-ref args 1)
|
||||||
|
(d-hash-ref messages 'item-added-suffix)]
|
||||||
[(and (equal? args-length 2) (equal? (vector-member "remove" args) 0))
|
[(and (equal? args-length 2) (equal? (vector-member "remove" args) 0))
|
||||||
(d-hash-ref 'item-removed)]
|
(d-hash-ref messages 'item-removed-prefix)]
|
||||||
[(and (equal? args-length 1) (equal? (vector-member "init" args) 0))
|
[(and (equal? args-length 1) (equal? (vector-member "init" args) 0))
|
||||||
(todo-list-exist?)]
|
(todo-list-exist?)]
|
||||||
[else (d-hash-ref 'incorrect-usage)])))
|
[else (d-hash-ref messages 'incorrect-usage)])))
|
||||||
|
|
||||||
;; does the file exist that holds the list(s?)
|
;; does the file exist that holds the list(s?)
|
||||||
(define (todo-list-exist?)
|
(define (todo-list-exist?)
|
||||||
(if (check-for-folder)
|
(if (check-for-folder)
|
||||||
(d-hash-ref 'already-exists)
|
(d-hash-ref messages 'already-exists)
|
||||||
(prompt-user 'not-found)))
|
(prompt-user 'not-found)))
|
||||||
|
|
||||||
(define (main)
|
(define (main)
|
||||||
|
|
Loading…
Reference in New Issue