this push will break everything because I'm rewriting a lot of stuff

main
m455 2019-11-19 21:50:28 -05:00
parent ee112a9c71
commit 5563820688
5 changed files with 126 additions and 113 deletions

View File

@ -1,6 +1,6 @@
# rodo # rodo
A minimal todo list program for people who live on the command line. A minimal list manager for people who live on the command line.
# Screenshot # Screenshot
@ -54,17 +54,17 @@ If you are using a single-file executable, create a wrapper as follows:
# Introduction # Introduction
This readme will guide you through downloading, installing, and using the rodo This readme will guide you through downloading, installing, and using the rodo
todo list program. It is intended for people who spend a lot of their time on the list manager. It is intended for people who spend a lot of their time on the
command line and want a minimal todo list application. command line and want a minimal list manager.
# Conventions used in this readme # Conventions used in this readme
* Notes - Notes signify additional information * **Note** - Notes signify additional information
* Tips - Tips signify an alternate procedure for completing a step * **Tip**- Tips signify an alternate procedure for completing a step
* Cautions - Cautions signify that damage may occur * **Caution** - Cautions signify that damage may occur
* Examples - Examples provide a visual reference of how a procedure would be carried out in the real world * **Example** - Examples provide a visual reference of how a procedure would be carried out in the real world
* `Inline code` - Inline code signifies package names, filenames, or commands * `Inline code` - Inline code signifies package names, filenames, or commands
* ```Code blocks``` - Code blocks signify file contents * ```Code block``` - Code blocks signify file contents
# Platforms # Platforms
@ -191,5 +191,5 @@ The examples below assume that you have [added rodo to your $PATH](#adding-rodo-
**Caution**: Changing the `config.rkt` file should be done at your own risk as it may break rodo's functionality **Caution**: Changing the `config.rkt` file should be done at your own risk as it may break rodo's functionality
Settings such as the program name, directory, and the filename of the todo list Settings such as the program name, directory, and the filename of the list
file can be changed by editing the `config.rkt` file. file can be changed by editing the `config.rkt` file.

View File

@ -14,27 +14,27 @@
[(equal? args-length 0) [(equal? args-length 0)
(utils:display-hash-ref messages:messages 'show-usage)] (utils:display-hash-ref messages:messages 'show-usage)]
;; help ;; help-command
[(and (equal? args-length 1) [(and (equal? args-length 1)
(member (list-ref args 0) config:help-command)) (member (list-ref args 0) config:help-command))
(utils:display-hash-ref messages:messages 'show-help)] (utils:display-hash-ref messages:messages 'show-help)]
;; init ;; initialize-command
[(and (equal? args-length 1) [(and (equal? args-length 1)
(member (list-ref args 0) config:initialize-command)) (member (list-ref args 0) config:initialize-command))
(init:initialize)] (init:initialize)]
;; add ;; add-command
[(and (or (equal? args-length 2) (>= args-length 2)) [(and (or (equal? args-length 2) (>= args-length 2))
(member (list-ref args 0) config:add-command)) (member (list-ref args 0) config:add-command))
(utils:add-item-to-list config:list-file args)] (utils:add-item-to-list config:list-file args)]
;; ls ;; list-command
[(and (equal? args-length 1) [(and (equal? args-length 1)
(member (list-ref args 0) config:list-command)) (member (list-ref args 0) config:list-command))
(utils:show-list-from-file config:list-file)] (utils:show-list-from-file config:list-file)]
;; rm ;; remove-command
[(and (equal? args-length 2) [(and (equal? args-length 2)
(member (list-ref args 0) config:remove-command) (member (list-ref args 0) config:remove-command)
(real? (string->number (list-ref args 1))) (real? (string->number (list-ref args 1)))

View File

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(provide (all-defined-out)) (provide (all-defined-out))
(define file-name "todo.txt") (define file-name "list.txt")
(define program-name "rodo") (define program-name "rodo")
(define program-directory (define program-directory
@ -12,22 +12,27 @@
(define list-file (define list-file
(string-append program-directory file-name)) (string-append program-directory file-name))
;; TODO: pluralize this value's name
(define help-command '("-h" (define help-command '("-h"
"--help" "--help"
"h" "h"
"help")) "help"))
;; TODO: pluralize this value's name
(define initialize-command '("init" (define initialize-command '("init"
"create" "create"
"start" "start"
"begin")) "begin"))
;; TODO: pluralize this value's name
(define add-command '("add" (define add-command '("add"
"a")) "a"))
;; TODO: pluralize this value's name
(define list-command '("ls" (define list-command '("ls"
"list")) "list"))
;; TODO: pluralize this value's name
(define remove-command '("rm" (define remove-command '("rm"
"remove" "remove"
"del" "del"

View File

@ -4,129 +4,137 @@
(provide (all-defined-out)) (provide (all-defined-out))
(define newline "\n")
(define messages (define messages
(hash (hash
'show-help (string-append 'show-help
"Usage\n" (string-append "\n"
"=====\n" "Conventions used in this help message\n"
(format "If you want to use the ~a or ~a commands, follow the structure below:\n" "====================================="
config:initialize-command "\n\n"
config:list-command) "[command] - [command]s should be replaced by a command from the Command section below without the surrounding \"[\" and \"]\"s."
(format "~a <command>\n\n" "\n\n"
config:program-name) "<argument> - <argument>s should be replaced by user input without the surrounding \"<\" and \">\"s."
"\n\n"
"Command descriptions\n"
"===================="
"\n\n"
(format "If you want to use the ~a or ~a commands, follow the structure below:\n" ;; initialize-command
config:add-command (format "~a" (car config:initialize-command))
config:remove-command) "\n\n"
(format "~a <command> [argument]\n\n" config:program-name) "\t"
(format "Creates a list in ~a." config:list-file)
"\n\n"
"Note: Replace <command> with one of the Commands below without the surrounding \"<\" and \">\".\n\n" ;; list-command
(format "~a" (car config:list-command))
"\n\n"
"\t"
"Displays items in your list."
"\n\n"
"Commands\n" ;; add-command
"========\n" (format "~a" (car config:add-command))
(format "This section describes the commands available for ~a.\n\n" config:program-name) "\n\n"
(format "Note: The commands mentioned in this section should replace the \"<command>\" filler text found in the Usage section above.\n\n") "\t"
"Adds an item to your list."
"\n\n"
;; init ;; remove-command
(format "~a\n" config:initialize-command) (format "~a" (car config:remove-command))
"====\n" "\n\n"
(format "Creates ~a in ~a. This is where your todo list will be stored.\n\n" "\t"
config:list-file "Removes an item from your list."
config:program-directory) "\n\n"
"Example:\n" "Usage examples\n"
(format "~a ~a\n\n" config:program-name config:initialize-command) "=============="
"\n\n"
;; initialize-command
(format "~a" (car config:initialize-command))
"\n\n"
"\t"
(format "~a ~a" config:program-name (car config:initialize-command))
"\n\n"
;; ls ;; list-command
(format "~a\n" config:list-command) (format "~a" (car config:list-command))
"====\n" "\n\n"
"Displays items in your todo list.\n\n" "\t"
(format "~a ~a" config:program-name (car config:list-command))
"\n\n"
"Example:\n" ;; add-command
(format "~a ~a\n\n" config:program-name config:list-command) (format "~a" (car config:add-command))
"\n\n"
"\t"
(format "~a ~a this is an item without double quotation marks" config:program-name (car config:add-command))
"\n\n"
"\t"
(format "~a ~a \"this is an item surrounded by double quotation marks\"" config:program-name (car config:add-command))
"\n\n"
"\t"
"Note: Grave accents (`) and single quotation marks (\') cannot be used with this command."
"\n\n"
(format "~a [argument(s)]\n" config:add-command) ;; remove-command
"=================\n" (format "~a" (car config:remove-command))
"Adds an item to the list.\n\n" "\n\n"
"\t"
(format "~a ~a 2" config:program-name (car config:remove-command))
"\n\n"
"\t"
"Note: The example above will remove the third item from your list, because the list starts at zero."
"\n\n"
"Examples:\n" "Can't see the whole help message?\n"
(format "~a ~a this is an unquoted item\n" config:program-name config:add-command) "================================="
(format "~a ~a \"this is a quoted item\"\n\n" config:program-name config:add-command) "\n\n"
"\t"
(format "Try running \"~a -h | less\" (without the double quotation marks), so you can use the arrow keys to scroll up and down." config:program-name)
"\n\n"
"\t"
"When you want to quit, type \"q\" (without the double quotation marks)."
"\n\n")
(format "~a [argument]\n" config:remove-command) 'empty-list "> There is nothing in your list.\n"
"=============\n"
"Removes an item from the list.\n\n"
"Example:\n" 'show-usage (format "> For usage type \"~a -h\" (without the double quotation marks).\n" config:program-name)
(format "~a ~a 1\n\n" config:program-name config:remove-command)
(format "Note: You may have to run `~a ~a` to see which number corresponds to which item in your todo list." 'creating (format "> Creating a list in ~a...\n" config:list-file)
config:program-name
config:list-command)
" "
"In the example above, the first item was removed from the todo list.\n\n"
"Can't see the whole help message?\n" 'creation-error (format "> Error: Could not create a list file in ~a.\n" config:list-file)
"=================================\n"
(format "Try running `~a -h | less` so you can use the arrow keys to scroll up and down."
config:program-name)
" "
"When you want to quit, type `q` (without the grave accents).\n")
'empty-todo-list "> There is nothing in your list.\n" 'file-already-exists (format "> Error: A list file already exists in ~a.\n" config:list-file)
'show-usage (format "> For usage type `~a -h` or `~a --help`.\n" 'successfully-created (format "> Your list file was successfully created in ~a.\n" config:list-file)
config:program-name
config:program-name)
'creating (format "> Creating ~a in ~a.\n" 'file-not-found (format "> Error: Could not find ~a.\n" config:list-file)
config:list-file
config:program-directory)
'creation-error (string-append 'item-not-found "> Error: Could not find that item.\n"
(format "> Error: Could not create a(n) ~a in ~a.\n"
config:list-file
config:program-directory)
"> This might be due to directory permissions.\n")
'file-already-exists (format "> Error: ~a already exists in ~a~a.\n" 'init-y/n (format (string-append "> A list file will be created in ~a.\n"
config:program-name "> Are you sure you want to continue? [y/n].\n")
config:program-directory config:list-file)
config:list-file)
'successfully-created (format "> ~a has been successfully created in ~a.\n" 'try-init (format "> Try typing \"~a ~a\" to set it up (without the double quotation marks).\n"
config:program-directory config:program-name (car config:initialize-command))
config:list-file)
'file-not-found (format "> Error: Could not find ~a~a\n" 'terminating (format "> Exited ~a.\n" config:program-name)
config:program-directory
config:list-file)
'item-not-found "> Error: Could not find that item\n" 'choose-y/n "> Error: Please choose y or n\n"
'init-y/n (string-append 'not-in-list "> Error: Item does not exist\n"
(format "> ~a will be created in ~a.\n"
config:list-file
config:program-directory)
"> Are you sure you want to continue? [y/n]\n")
'try-init (format "> Try typing `~a ~a` to set it up (without the grave accents).\n" 'item-added-prefix "> Added "
config:program-name
(car config:initialize-command))
'terminating (format "> Exiting ~a\n" config:program-name) 'item-added-suffix " to list\n"
'choose-y/n "> Error: Please choose y or n\n" 'item-removed-prefix "> Removed "
'not-in-list "> Error: Item does not exist\n" 'item-removed-suffix " from list\n"))
'item-added-prefix "> Added "
'item-added-suffix " to list\n"
'item-removed-prefix "> Removed "
'item-removed-suffix " from list\n"))
(define y/n (hash 'yes '("yes" "Yes" "y" "Y") (define y/n (hash 'yes '("yes" "Yes" "y" "Y")
'no '("no" "No" "n" "N"))) 'no '("no" "No" "n" "N")))

View File

@ -63,7 +63,7 @@
;; If exists and empty ;; If exists and empty
[(and (file-exists? config:list-file) [(and (file-exists? config:list-file)
(null? (file:file->lines a-file))) (null? (file:file->lines a-file)))
(display-hash-ref messages:messages 'empty-todo-list)] (display-hash-ref messages:messages 'empty-list)]
;; If not exist ;; If not exist
[(and (not (file-exists? config:list-file))) [(and (not (file-exists? config:list-file)))
@ -101,7 +101,7 @@
[(and (directory-exists? config:program-directory) [(and (directory-exists? config:program-directory)
(file-exists? config:list-file) (file-exists? config:list-file)
(null? config:list-file)) (null? config:list-file))
(display-hash-ref messages:messages 'empty-todo-list)] (display-hash-ref messages:messages 'empty-list)]
;; If directory and file exist, and file is not empty ;; If directory and file exist, and file is not empty
[(and (directory-exists? config:program-directory) [(and (directory-exists? config:program-directory)