changed name util to utils

main
m455 2019-11-13 13:59:02 -05:00
parent 26c4c340b4
commit fa2bd383fb
3 changed files with 20 additions and 20 deletions

View File

@ -4,24 +4,24 @@
(prefix-in config: "config.rkt")
(prefix-in init: "init.rkt")
(prefix-in messages: "messages.rkt")
(prefix-in util: "util.rkt"))
(prefix-in utils: "utils.rkt"))
(provide (all-defined-out))
(define (check-args args)
(let ([args-length (vector-length args)])
(cond [(equal? args-length 0)
(util:display-hash-ref messages:messages 'show-usage)]
(utils:display-hash-ref messages:messages 'show-usage)]
;; ls
[(and (equal? args-length 1)
(equal? (vector:vector-member config:list-command args) 0))
(util:show-list-from-file config:path-to-list-file)]
(utils:show-list-from-file config:path-to-list-file)]
;; add
[(and (or (equal? args-length 2) (>= args-length 2))
(equal? (vector-ref args 0) config:add-command))
(util:add-item-to-list config:path-to-list-file args)]
(utils:add-item-to-list config:path-to-list-file args)]
;; rm
[(and (equal? args-length 2)
@ -30,8 +30,8 @@
(or (positive? (string->number (vector-ref args 1)))
(zero? (string->number (vector-ref args 1))))
;; Length subtract one because the numbering starts at zero
(not (> (string->number (vector-ref args 1)) (sub1 (length (util:file->string-list config:path-to-list-file))))))
(util:remove-item-from-list config:path-to-list-file args)]
(not (> (string->number (vector-ref args 1)) (sub1 (length (utils:file->string-list config:path-to-list-file))))))
(utils:remove-item-from-list config:path-to-list-file args)]
;; init
[(and (equal? args-length 1)
@ -41,7 +41,7 @@
;; help
[(and (equal? args-length 1)
(member (vector-ref args 0) config:help-command))
(util:display-hash-ref messages:messages 'show-help)]
(utils:display-hash-ref messages:messages 'show-help)]
[else
(util:display-hash-ref messages:messages 'show-usage)])))
(utils:display-hash-ref messages:messages 'show-usage)])))

View File

@ -2,30 +2,30 @@
(require (prefix-in config: "config.rkt")
(prefix-in messages: "messages.rkt")
(prefix-in util: "util.rkt"))
(prefix-in utils: "utils.rkt"))
(provide (all-defined-out))
(define (init-prompt hash-list key)
(util:display-hash-ref hash-list key)
(utils:display-hash-ref hash-list key)
(display "> ")
(let ([user-input (read-line)])
(cond [(member user-input (hash-ref messages:y/n 'yes))
(begin
(util:display-hash-ref messages:messages 'creating)
(util:create-program-directory-700 config:program-directory)
(util:create-list-file-600 config:path-to-list-file)
(if (and (util:program-directory-exists?)
(util:list-file-exists?))
(util:display-hash-ref messages:messages 'successfully-created)
(util:display-hash-ref messages:messages 'creation-error)))]
(utils:display-hash-ref messages:messages 'creating)
(utils:create-program-directory-700 config:program-directory)
(utils:create-list-file-600 config:path-to-list-file)
(if (and (utils:program-directory-exists?)
(utils:list-file-exists?))
(utils:display-hash-ref messages:messages 'successfully-created)
(utils:display-hash-ref messages:messages 'creation-error)))]
[(member user-input (hash-ref messages:y/n 'no))
(util:display-hash-ref messages:messages 'terminating)]
(utils:display-hash-ref messages:messages 'terminating)]
[else
(init-prompt messages:messages 'choose-y/n)])))
(define (initialize)
(if (util:list-file-exists?)
(util:display-hash-ref messages:messages 'file-already-exists)
(if (utils:list-file-exists?)
(utils:display-hash-ref messages:messages 'file-already-exists)
(begin
(init-prompt messages:messages 'init-y/n))))

View File