2019-08-25 22:37:34 +00:00
|
|
|
#lang racket/base
|
|
|
|
|
|
|
|
(require (prefix-in config: "config.rkt"))
|
|
|
|
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
2019-11-22 18:35:25 +00:00
|
|
|
(define (indent string)
|
|
|
|
(string-append "\t" string))
|
2019-11-20 02:50:28 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(define newline "\n")
|
|
|
|
(define newline-double "\n\n")
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2019-08-25 22:37:34 +00:00
|
|
|
(define messages
|
2020-04-11 20:43:14 +00:00
|
|
|
(hash 'show-help (string-append
|
|
|
|
"NAME" newline
|
|
|
|
"====" newline
|
|
|
|
"rodo" newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
"DESCRIPTION" newline
|
|
|
|
"===========" newline
|
|
|
|
"rodo is a minimalistic list-management tool. It does not use any data formats, and cannot remove multiple items at once." newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
"USAGE SYNTAX" newline
|
|
|
|
"============" newline
|
|
|
|
"rodo [command] <args>" newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
"COMMANDS AVAILABLE" newline
|
|
|
|
"==================" newline
|
|
|
|
(car config:initialize-commands) " - " (format "Creates a list file located at ~a" config:list-file) newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:list-commands) " - " "Displays items from your list" newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:add-commands) " <args> - Adds an item to your list" newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:remove-commands) " <args> - Removes an item from your list" newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
"USAGE EXAMPLES" newline
|
|
|
|
"==============" newline
|
|
|
|
(car config:initialize-commands) " usage:" newline
|
|
|
|
(format "~a ~a" config:program-name (car config:initialize-commands)) newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:list-commands) " usage:" newline
|
|
|
|
(format "~a ~a" config:program-name (car config:list-commands)) newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:add-commands) " usage:" newline
|
|
|
|
(format "~a ~a this is an item without double quotation marks" config:program-name (car config:add-commands)) newline
|
|
|
|
(format "~a ~a \"this is an item surrounded by double quotation marks\"" config:program-name (car config:add-commands)) newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
(car config:remove-commands) " usage:" newline
|
|
|
|
(format "~a ~a 2" config:program-name (car config:remove-commands)) newline-double
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
"Can't see the whole help message?" newline
|
|
|
|
"=================================" newline
|
|
|
|
"Try running the command below:" newline
|
|
|
|
(format "~a ~a | less" config:program-name (car config:help-commands)) newline)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'empty-list "> There is nothing in your list\n"
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'show-usage (format "> For usage type ~a -h\n" config:program-name)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'creating (format "> Creating a list in ~a...\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'creation-error (format "> Error: Could not create a list file in ~a\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'file-already-exists (format "> Error: A list file already exists in ~a\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'successfully-created (format "> Your list file was successfully created in ~a\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'file-not-found (format "> Error: Could not find ~a\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'item-not-found "> Error: Could not find that item\n"
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'init-y/n (format "> A list file will be created in ~a\n> Are you sure you want to continue? [y/n]\n" config:list-file)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'try-init (format "> Try typing ~a ~a to set it up\n" config:program-name (car config:initialize-commands))
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'terminating (format "> Exited ~a\n" config:program-name)
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'choose-y/n "> Error: Please choose y or n\n"
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'not-in-list "> Error: Item does not exist\n"
|
2020-02-09 20:58:38 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'item-added "> Added \"~a\" to your list\n"
|
2019-11-20 02:50:28 +00:00
|
|
|
|
2020-04-11 20:43:14 +00:00
|
|
|
'item-removed "> Removed \"~a\" from your list\n"))
|
2019-08-25 22:37:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
(define y/n (hash 'yes '("yes" "Yes" "y" "Y")
|
2019-11-20 02:50:28 +00:00
|
|
|
'no '("no" "No" "n" "N")))
|