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 config: "config.rkt")
(prefix-in init: "init.rkt") (prefix-in init: "init.rkt")
(prefix-in messages: "messages.rkt") (prefix-in messages: "messages.rkt")
(prefix-in util: "util.rkt")) (prefix-in utils: "utils.rkt"))
(provide (all-defined-out)) (provide (all-defined-out))
(define (check-args args) (define (check-args args)
(let ([args-length (vector-length args)]) (let ([args-length (vector-length args)])
(cond [(equal? args-length 0) (cond [(equal? args-length 0)
(util:display-hash-ref messages:messages 'show-usage)] (utils:display-hash-ref messages:messages 'show-usage)]
;; ls ;; ls
[(and (equal? args-length 1) [(and (equal? args-length 1)
(equal? (vector:vector-member config:list-command args) 0)) (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 ;; add
[(and (or (equal? args-length 2) (>= args-length 2)) [(and (or (equal? args-length 2) (>= args-length 2))
(equal? (vector-ref args 0) config:add-command)) (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 ;; rm
[(and (equal? args-length 2) [(and (equal? args-length 2)
@ -30,8 +30,8 @@
(or (positive? (string->number (vector-ref args 1))) (or (positive? (string->number (vector-ref args 1)))
(zero? (string->number (vector-ref args 1)))) (zero? (string->number (vector-ref args 1))))
;; Length subtract one because the numbering starts at zero ;; 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)))))) (not (> (string->number (vector-ref args 1)) (sub1 (length (utils:file->string-list config:path-to-list-file))))))
(util:remove-item-from-list config:path-to-list-file args)] (utils:remove-item-from-list config:path-to-list-file args)]
;; init ;; init
[(and (equal? args-length 1) [(and (equal? args-length 1)
@ -41,7 +41,7 @@
;; help ;; help
[(and (equal? args-length 1) [(and (equal? args-length 1)
(member (vector-ref args 0) config:help-command)) (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 [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") (require (prefix-in config: "config.rkt")
(prefix-in messages: "messages.rkt") (prefix-in messages: "messages.rkt")
(prefix-in util: "util.rkt")) (prefix-in utils: "utils.rkt"))
(provide (all-defined-out)) (provide (all-defined-out))
(define (init-prompt hash-list key) (define (init-prompt hash-list key)
(util:display-hash-ref hash-list key) (utils:display-hash-ref hash-list key)
(display "> ") (display "> ")
(let ([user-input (read-line)]) (let ([user-input (read-line)])
(cond [(member user-input (hash-ref messages:y/n 'yes)) (cond [(member user-input (hash-ref messages:y/n 'yes))
(begin (begin
(util:display-hash-ref messages:messages 'creating) (utils:display-hash-ref messages:messages 'creating)
(util:create-program-directory-700 config:program-directory) (utils:create-program-directory-700 config:program-directory)
(util:create-list-file-600 config:path-to-list-file) (utils:create-list-file-600 config:path-to-list-file)
(if (and (util:program-directory-exists?) (if (and (utils:program-directory-exists?)
(util:list-file-exists?)) (utils:list-file-exists?))
(util:display-hash-ref messages:messages 'successfully-created) (utils:display-hash-ref messages:messages 'successfully-created)
(util:display-hash-ref messages:messages 'creation-error)))] (utils:display-hash-ref messages:messages 'creation-error)))]
[(member user-input (hash-ref messages:y/n 'no)) [(member user-input (hash-ref messages:y/n 'no))
(util:display-hash-ref messages:messages 'terminating)] (utils:display-hash-ref messages:messages 'terminating)]
[else [else
(init-prompt messages:messages 'choose-y/n)]))) (init-prompt messages:messages 'choose-y/n)])))
(define (initialize) (define (initialize)
(if (util:list-file-exists?) (if (utils:list-file-exists?)
(util:display-hash-ref messages:messages 'file-already-exists) (utils:display-hash-ref messages:messages 'file-already-exists)
(begin (begin
(init-prompt messages:messages 'init-y/n)))) (init-prompt messages:messages 'init-y/n))))

View File