cleaned up messages.rkt

main
m455 2019-08-25 18:37:34 -04:00
parent 9abb50b9bd
commit 7376d8efff
2 changed files with 156 additions and 180 deletions

View File

@ -9,130 +9,110 @@
'show-help (string-append 'show-help (string-append
"Usage\n" "Usage\n"
"=====\n" "=====\n"
"If you are using the " (format "If you want to use the ~a or ~a commands, follow the structure below:\n"
"<" config:initialize-command ">" " or " config:initialize-command
"<" config:list-command ">" " commands, follow the structure below:\n" config:list-command)
config:program-name " <command>\n" (format "~a <command>\n\n"
"\n" config:program-name)
"If you are using the " (format "If you want to use the ~a or ~a commands, follow the structure below:\n"
"<" config:add-command ">" " or " config:add-command
"<" config:remove-command ">" " commands, follow the structure below:\n" config:remove-command)
config:program-name " <command> [argument]\n" (format "~a <command> [argument]\n\n" config:program-name)
"\n"
"Note: Replace <command> with one of the Commands below without the surrounding \"<\" and \">\".\n\n"
"Commands\n" "Commands\n"
"========\n" "========\n"
(format "This section describes the commands available for ~a.\n\n" config:program-name)
(format "Note: The commands mentioned in this section should replace the \"<command>\" filler text found in the Usage section above.\n\n")
"<" config:initialize-command ">" ":\n" ;; init
"Create a file in " (format "~a\n" config:initialize-command)
"====\n"
(format "Creates a file in ~a~a. This is where your to-do list will be stored.\n\n"
config:program-directory config:program-directory
config:program-file config:program-file)
" where your to-do list will be stored\n"
"Example:\n"
config:program-name " "
config:initialize-command "\n"
"\n"
"<" config:list-command ">" ":\n"
"Displays items in the list\n"
"Example:\n" "Example:\n"
config:program-name " " (format "~a ~a\n\n" config:program-name config:initialize-command)
config:list-command "\n"
"\n" ;; ls
(format "~a\n" config:list-command)
"====\n"
"Displays items in your to-do list.\n\n"
"<" config:add-command ">" " "
"[argument]:\n"
"Adds an item to the list\n"
"Example:\n" "Example:\n"
config:program-name " " (format "~a ~a\n\n" config:program-name config:list-command)
config:add-command " "
"bread\n" (format "~a [argument(s)]\n" config:add-command)
config:program-name " " "=================\n"
config:add-command " " "Adds an item to the list.\n\n"
"this is an unquoted task\n"
config:program-name " " "Examples:\n"
config:add-command " " (format "~a ~a this is an unquoted item\n" config:program-name config:add-command)
"\"this is a quoted task which isn't any different from an unquoted task\"\n" (format "~a ~a \"this is a quoted item\"\n\n" config:program-name config:add-command)
"\n"
(format "~a [argument]\n" config:remove-command)
"=============\n"
"Removes an item from the list\n\n"
"<" config:remove-command ">" " "
"[argument]:\n"
"Removes an item from the list\n"
"Example:\n" "Example:\n"
config:program-name " " config:remove-command " " "1\n" (format "~a ~a 1\n\n" config:program-name config:remove-command)
"\n"
"Note:\n" (format "Note: You may have to run `~a ~a` to see which number corresponds to which item in your to-do list."
"You may have to run " config:program-name
"`" config:program-name " " config:list-command "`" " " config:list-command)
"see which number corresponds to which item in the list." " "
" In the example above, the first item was removed from the list\n" "In the example above, the first item was removed from the to-do list.\n\n"
"\n"
"Can't see the whole help message?\n" "Can't see the whole help message?\n"
"=================================\n" "=================================\n"
"Try running " (format "Try running `~a -h | less` so you can use the arrow keys to scrolll up and down."
"`" config:program-name " -h | less` to use the arrow keys " config:program-name)
"to scroll up and down through the help message, then when you " " "
"want to quit, just type `q` (without the grave accents)\n") "When you want to quit, type `q` (without the grave accents).")
'empty-to-do-list "> There is nothing in your list \n" 'empty-to-do-list "> There is nothing in your list \n"
'show-usage (string-append 'show-usage (format "> For usage type `~a -h` or `~a --help`\n"
"> For usage type " config:program-name
"`" config:program-name " -h`" config:program-name)
" or "
"`" config:program-name " --help`\n")
'creating (string-append 'creating (format "> Creating a(n) ~a file in ~a\n"
"> Creating "
config:program-file config:program-file
" file in " config:program-directory)
config:program-directory "\n")
'creation-error (string-append 'creation-error (string-append
"> Error: Could not create " (format "> Error: Could not create a(n) ~a in ~a.\n"
config:program-file config:program-file
" in " config:program-directory)
config:program-directory "> This might be due to directory permissions\n")
".\n"
"> This may be due to directory permissions\n")
'file-already-exists (string-append 'file-already-exists (format "> Error: ~a already exists in ~a~a.\n"
"> Error: "
config:program-name config:program-name
" already exists in "
config:program-directory config:program-directory
config:program-file "\n") config:program-file)
'successfully-created (string-append 'successfully-created (format "> ~a~a has been successfully created\n"
"> "
config:program-directory config:program-directory
config:program-file config:program-file)
" has been successfully created\n")
'file-not-found (string-append 'file-not-found (format "> Error: Could not find ~a~a\n"
"> Error: Could not find "
config:program-directory config:program-directory
config:program-file "\n") config:program-file)
'init-y/n (string-append 'init-y/n (string-append
"> A " (format "> A ~a file will be created in the ~a directory.\n"
config:program-file config:program-file
" file will be created in the directory " config:program-directory)
config:program-directory "\n"
"> Are you sure you want to continue? [y/n]\n") "> Are you sure you want to continue? [y/n]\n")
'try-init (string-append 'try-init (format "> Try typing `~a ~a` to set it up (without the grave accents).\n"
"> Try typing "
"`" config:program-name " init` "
"to set it up\n")
'terminating (string-append
"> Exiting "
config:program-name config:program-name
"\n") config:initialize-command)
'terminating (format "> Exiting ~a\n" config:program-name)
'choose-y/n "> Error: Please choose y or n\n" 'choose-y/n "> Error: Please choose y or n\n"
@ -146,8 +126,5 @@
'item-removed-suffix " from list\n")) 'item-removed-suffix " from list\n"))
(define y/n (define y/n (hash 'yes '("yes" "Yes" "y" "Y")
(hash
'yes '("yes" "Yes" "y" "Y")
'no '("no" "No" "n" "N"))) 'no '("no" "No" "n" "N")))

View File

@ -65,7 +65,6 @@
"\n" "\n"
#:after-last "\n"))) #:after-last "\n")))
;; Don't ask
(define (append-item-to-end args lst) (define (append-item-to-end args lst)
(reverse (cons args (reverse (file->string-list lst))))) (reverse (cons args (reverse (file->string-list lst)))))
@ -104,7 +103,7 @@
(define (add-item-to-list args) (define (add-item-to-list args)
(if (and (check-for-program-directory) (if (and (check-for-program-directory)
(check-for-program-file)) (check-for-program-file))
;; The cdr here prevents the first command line argument ("add") ;; The cdr here prevents user commands, such as "add"
;; from being added to the file ;; from being added to the file
(write-item-to-program-file (string:string-join (cdr (vector->list args)))) (write-item-to-program-file (string:string-join (cdr (vector->list args))))
;; Else ;; Else