splitting functions into different files

main
m455 2018-04-10 12:53:34 -04:00
parent e0e75438f5
commit f7823deebc
3 changed files with 120 additions and 111 deletions

12
config.rkt 100644
View File

@ -0,0 +1,12 @@
#lang racket/base
(provide (all-defined-out))
(define program-name "rodo")
(define program-directory ".rodo/")
(define program-path "~/")
(define program-file "todo-list")
(define remove-command "rm")
(define add-command "add")
(define list-command "ls")
(define initialize-command "init")

105
messages.rkt 100644
View File

@ -0,0 +1,105 @@
#lang racket/base
(require "config.rkt")
(provide (all-defined-out))
(define messages
(hash
'show-usage
(string-append
"> For usage type "
"`" program-name " -h`"
" or "
"`" program-name " --help`\n")
'creating-folder
(string-append
"> creating a "
program-directory
" folder in "
program-path " ...\n")
'creating-file
(string-append
"> creating a "
program-file
" file in "
program-path
program-directory " ...\n")
'creation-error
(string-append
"> Error: Could not create "
program-file
" in "
program-directory
program-path ".\n"
"> This may be due to directory permissions\n")
'file-already-exists
(string-append
"> Error: "
program-name
" already exists in "
program-path
program-directory
program-file "\n")
'successfully-created
(string-append
"> "
program-path
program-directory
program-file
" has been successfully created\n")
'file-not-found
(string-append
"> Error: Could not find "
program-path
program-directory
program-file "\n")
'init-y/n
(string-append
"> A "
program-file
" file will be created in "
program-path
program-directory "\n"
"> Are you sure you want to continue? [y/n]\n")
'try-init
(string-append
"> Try typing "
"`" program-name " init` "
"to set it up\n")
'terminating
(string-append
"> Exiting "
program-name
" ...\n")
'choose-y/n
"> Error: Please choose y or n\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")
'no
'("no" "No" "n" "N")))

114
rodo.rkt
View File

@ -4,16 +4,9 @@
(require racket/vector
racket/file
racket/string
racket/list)
(define program-name "rodo")
(define program-directory ".rodo/")
(define program-path "~/")
(define program-file "todo-list")
(define remove-command "rm")
(define add-command "add")
(define list-command "ls")
(define initialize-command "init")
racket/list
"config.rkt"
"messages.rkt")
(define (d-hash-ref hash-list key)
(display (hash-ref hash-list key)))
@ -21,107 +14,6 @@
(define (d-vector-ref args key)
(display (vector-ref args key)))
(define messages
(hash
'show-usage
(string-append
"> For usage type "
"`" program-name " -h`"
" or "
"`" program-name " --help`\n")
'creating-folder
(string-append
"> creating a "
program-directory
" folder in "
program-path " ...\n")
'creating-file
(string-append
"> creating a "
program-file
" file in "
program-path
program-directory " ...\n")
'creation-error
(string-append
"> Error: Could not create "
program-file
" in "
program-directory
program-path ".\n"
"> This may be due to directory permissions\n")
'file-already-exists
(string-append
"> Error: "
program-name
" already exists in "
program-path
program-directory
program-file "\n")
'successfully-created
(string-append
"> "
program-path
program-directory
program-file
" has been successfully created\n")
'file-not-found
(string-append
"> Error: Could not find "
program-path
program-directory
program-file "\n")
'init-y/n
(string-append
"> A "
program-file
" file will be created in "
program-path
program-directory "\n"
"> Are you sure you want to continue? [y/n]\n")
'try-init
(string-append
"> Try typing "
"`" program-name " init` "
"to set it up\n")
'terminating
(string-append
"> Exiting "
program-name
" ...\n")
'choose-y/n
"> Error: Please choose y or n\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")
'no
'("no" "No" "n" "N")))
(define (check-for-file)
(file-exists?
(expand-user-path