rodo/init.rkt

37 lines
1.2 KiB
Racket
Raw Normal View History

2018-10-10 17:55:52 +00:00
#lang racket/base
2018-10-10 18:42:13 +00:00
(require (prefix-in file: racket/file)
(prefix-in config: "config.rkt")
(prefix-in util: "util.rkt")
(prefix-in messages: "messages.rkt"))
2018-10-10 17:55:52 +00:00
(provide (all-defined-out))
(define (init-prompt hash-list key)
2018-10-10 18:42:13 +00:00
(util:display-hash-ref hash-list key)
2018-10-10 17:55:52 +00:00
(display "> ")
(let
2018-10-10 18:42:13 +00:00
([user-input (read-line)])
2018-10-10 17:55:52 +00:00
(cond
2018-10-10 18:42:13 +00:00
[(member user-input (hash-ref messages:y/n 'yes))
(util:display-hash-ref messages:messages 'creating)
2019-05-25 13:49:06 +00:00
(util:create-program-directory)
(util:create-program-file)
2018-10-10 18:42:13 +00:00
(if (and
2019-05-25 13:49:06 +00:00
(util:check-for-program-directory)
(util:check-for-program-file))
2018-10-10 18:42:13 +00:00
(util:display-hash-ref messages:messages 'successfully-created)
(util:display-hash-ref messages:messages 'creation-error))]
2018-10-10 17:55:52 +00:00
2018-10-10 18:42:13 +00:00
[(member user-input (hash-ref messages:y/n 'no))
(util:display-hash-ref messages:messages 'terminating)]
2018-10-10 17:55:52 +00:00
[else
2018-10-10 18:42:13 +00:00
(init-prompt messages:messages 'choose-y/n)])))
2018-10-10 17:55:52 +00:00
(define (initialize)
2019-05-25 13:49:06 +00:00
(if (util:check-for-program-file)
2018-10-10 18:42:13 +00:00
(util:display-hash-ref messages:messages 'file-already-exists)
(begin
(init-prompt messages:messages 'init-y/n))))