rodo/init.rkt

48 lines
1.1 KiB
Racket
Raw Normal View History

2018-04-12 18:25:19 +00:00
#lang racket/base
2018-04-15 04:15:10 +00:00
(require racket/file
"config.rkt"
2018-04-12 18:37:01 +00:00
"util.rkt"
2018-04-12 18:25:19 +00:00
"messages.rkt"
"io.rkt")
(provide (all-defined-out))
2018-04-15 04:15:10 +00:00
(define (initialize-file)
(display-to-file
"--Do not edit this file--\n"
2018-04-15 04:15:10 +00:00
path
#:mode 'text
#:exists 'replace))
2018-04-12 18:25:19 +00:00
(define (init-prompt hash-list key)
(d-hash-ref hash-list key)
(display "> ")
(let
([user-input (read-line)])
(cond
[(member user-input (hash-ref y/n 'yes))
(d-hash-ref messages 'creating-folder)
(d-hash-ref messages 'creating-file)
(create-folder)
(create-file)
2018-04-15 04:15:10 +00:00
(initialize-file)
2018-04-12 18:25:19 +00:00
(if
(and
(check-for-folder)
(check-for-file))
(d-hash-ref messages 'successfully-created)
(d-hash-ref messages 'creation-error))]
[(member user-input (hash-ref y/n 'no))
(d-hash-ref messages 'terminating)]
[else
(init-prompt messages 'choose-y/n)])))
(define (initialize)
(if (check-for-file)
(d-hash-ref messages 'file-already-exists)
(begin
(init-prompt messages 'init-y/n))))