rodo/init.rkt

38 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-folder)
(util:display-hash-ref messages:messages 'creating-file)
(util:create-folder)
(util:create-file)
(if (and
(util:check-for-folder)
(util:check-for-file))
(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)
2018-10-10 18:42:13 +00:00
(if (util:check-for-file)
(util:display-hash-ref messages:messages 'file-already-exists)
(begin
(init-prompt messages:messages 'init-y/n))))