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))
|
|
|
|
|
2019-11-22 18:35:25 +00:00
|
|
|
(define (create-initialization-contents)
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(creating))
|
2020-04-12 15:57:19 +00:00
|
|
|
(utils:directory-create-700 config:program-directory)
|
|
|
|
(utils:file-create-600 config:list-file)
|
2019-11-22 18:35:25 +00:00
|
|
|
(if (and (directory-exists? config:program-directory)
|
|
|
|
(file-exists? config:list-file))
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(successfully-created))
|
2019-11-22 18:35:25 +00:00
|
|
|
;; Otherwise
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(creation-error))))
|
2019-11-22 18:35:25 +00:00
|
|
|
|
|
|
|
(define (initialize)
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(init-y/n))
|
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))
|
2019-11-22 18:35:25 +00:00
|
|
|
(create-initialization-contents)]
|
2019-11-04 02:32:11 +00:00
|
|
|
[(member user-input (hash-ref messages:y/n 'no))
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(terminating))]
|
|
|
|
[else (utils:display-messages '(choose-y/n))])))
|
2019-09-23 20:40:26 +00:00
|
|
|
|
2019-11-22 18:35:25 +00:00
|
|
|
(define (check-initialize-conditions)
|
2019-11-15 12:37:40 +00:00
|
|
|
(if (file-exists? config:list-file)
|
2020-01-03 19:21:08 +00:00
|
|
|
(utils:display-messages '(file-already-exists))
|
2019-11-22 18:35:25 +00:00
|
|
|
(initialize)))
|