updated hash list

main
m455 2018-04-05 22:42:18 -04:00
parent 3efc97a52e
commit 5f40569bf0
1 changed files with 28 additions and 10 deletions

View File

@ -49,9 +49,17 @@
"> " "> "
program-directory program-directory
" has not been setup in " " has not been setup in "
program-path "\n" program-path "\n")
'setup-y/n (string-append
"> Would you like to set it up now? [y/n]\n") "> Would you like to set it up now? [y/n]\n")
'try-initializing (string-append
"> Try typing "
"`" program-name
" init` "
"to set it up\n")
'choose-y/n "> Error: Please choose y or n\n" 'choose-y/n "> Error: Please choose y or n\n"
'item-added-prefix "> Added " 'item-added-prefix "> Added "
@ -108,13 +116,21 @@
[else [else
(prompt-user 'choose-y/n)]))) (prompt-user 'choose-y/n)])))
(define (add-item args)
(if (check-for-folder)
(begin
(d-hash-ref messages 'item-added-prefix)
(d-vector-ref args 1)
(d-hash-ref messages 'item-added-suffix))
(begin
(d-hash-ref messages 'not-found)
(d-hash-ref messages 'try-initializing))))
(define (check-args args) (define (check-args args)
(let ([args-length (vector-length args)]) (let ([args-length (vector-length args)])
(cond (cond
[(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 messages 'item-added-prefix) (add-item args)]
(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 messages 'item-removed-prefix) (d-hash-ref messages 'item-removed-prefix)
@ -122,17 +138,19 @@
(d-hash-ref messages 'item-removed-suffix)] (d-hash-ref messages 'item-removed-suffix)]
[(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-folder-exist?)]
[else (d-hash-ref messages '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-folder-exist?)
(if (check-for-folder) (if (check-for-folder)
(d-hash-ref messages 'already-exists) (d-hash-ref messages 'already-exists)
(prompt-user 'not-found))) (begin
(d-hash-ref messages 'not-found)
(prompt-user 'setup-y/n))))
(define (main) (define (main)
(check-args (current-command-line-arguments))) (check-args (current-command-line-arguments)))
(main) (main)