2019-09-23 20:40:26 +00:00
|
|
|
#lang racket/base
|
|
|
|
|
2019-11-13 15:50:24 +00:00
|
|
|
(require (prefix-in config: "config.rkt")
|
|
|
|
(prefix-in messages: "messages.rkt")
|
2019-11-13 18:59:02 +00:00
|
|
|
(prefix-in utils: "utils.rkt"))
|
2019-09-23 20:40:26 +00:00
|
|
|
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
|
|
|
(define (init-prompt hash-list key)
|
2019-11-13 18:59:02 +00:00
|
|
|
(utils:display-hash-ref hash-list key)
|
2019-09-23 20:40:26 +00:00
|
|
|
(display "> ")
|
2019-11-04 02:32:11 +00:00
|
|
|
(let ([user-input (read-line)])
|
|
|
|
(cond [(member user-input (hash-ref messages:y/n 'yes))
|
|
|
|
(begin
|
2019-11-13 18:59:02 +00:00
|
|
|
(utils:display-hash-ref messages:messages 'creating)
|
2019-11-15 12:37:40 +00:00
|
|
|
(utils:create-directory-700 config:program-directory)
|
|
|
|
(utils:create-file-600 config:list-file)
|
|
|
|
(if (and (directory-exists? config:program-directory)
|
|
|
|
(file-exists? config:list-file))
|
2019-11-13 18:59:02 +00:00
|
|
|
(utils:display-hash-ref messages:messages 'successfully-created)
|
|
|
|
(utils:display-hash-ref messages:messages 'creation-error)))]
|
2019-11-04 02:32:11 +00:00
|
|
|
[(member user-input (hash-ref messages:y/n 'no))
|
2019-11-13 18:59:02 +00:00
|
|
|
(utils:display-hash-ref messages:messages 'terminating)]
|
2019-11-04 02:32:11 +00:00
|
|
|
[else
|
|
|
|
(init-prompt messages:messages 'choose-y/n)])))
|
2019-09-23 20:40:26 +00:00
|
|
|
|
|
|
|
(define (initialize)
|
2019-11-15 12:37:40 +00:00
|
|
|
(if (file-exists? config:list-file)
|
2019-11-13 18:59:02 +00:00
|
|
|
(utils:display-hash-ref messages:messages 'file-already-exists)
|
2019-09-23 20:40:26 +00:00
|
|
|
(begin
|
|
|
|
(init-prompt messages:messages 'init-y/n))))
|