don't really remember what I changed lol

main
m455 2020-04-13 10:45:11 -04:00
parent 3004835bc0
commit 84cb77ce95
No known key found for this signature in database
GPG Key ID: 7FE7101DC135DE1F
2 changed files with 16 additions and 14 deletions

View File

@ -12,30 +12,32 @@
(let ([args-length (length args)]
[is-member? (lambda (command) (member (list-ref args 0) command))])
(cond
;; if no args
[(equal? args-length 0)
(utils:display-messages '(show-usage))]
;; help
;; if one arg, and arg is the help command
[(and (equal? args-length 1)
(is-member? config:help-commands))
(utils:display-messages '(show-help))]
;; initialize
;; if one arg, and arg is the initialize command
[(and (equal? args-length 1)
(is-member? config:initialize-commands))
(init:check-initialize-conditions)]
;; add
;; if two args, and the add command exists in one of those args
[(and (>= args-length 2)
(is-member? config:add-commands))
(utils:check-add-conditions args)]
;; list
;; if one arg, and arg is the list command
[(and (equal? args-length 1)
(is-member? config:list-commands))
(utils:check-list-conditions)]
;; remove
;; if two args, and the remove command exists in one of those args
[(and (>= args-length 2)
[(and (equal? args-length 2)
(is-member? config:remove-commands)
(real? (string->number (list-ref args 1)))

View File

@ -8,11 +8,13 @@
(provide (all-defined-out))
;; This may be affected by the user's umask
(define (file-create-600 a-file)
(let ([opened-file (open-output-file a-file #:mode 'text #:exists 'truncate)])
(close-output-port opened-file))
(file-or-directory-permissions a-file #o600))
;; This may be affected by the user's umask
(define (directory-create-700 a-directory)
(make-directory a-directory)
(file-or-directory-permissions a-directory #o700))
@ -34,9 +36,10 @@
lst))
(define (file->vertically-numbered-list a-file)
(string:string-join (list->numbered-list (file:file->lines a-file))
"\n"
#:after-last "\n"))
(string:string-join
(list->numbered-list (file:file->lines a-file))
"\n"
#:after-last "\n"))
(define (surround-with-quotation-marks item)
(string-append "\"" item "\""))
@ -79,9 +82,7 @@
(define (check-add-conditions args)
(if (and (file-exists? config:list-file))
(item-add args)
;; Otherwise
(display-messages '(file-not-found
try-init))))
(display-messages '(file-not-found try-init))))
(define (item-remove args)
(let* ([item-to-remove (list-ref (file:file->lines config:list-file) args)]
@ -97,7 +98,7 @@
(null? config:list-file))
(display-messages '(empty-list))]
;; If directory and file exist, and file is not empty
;; If directory and file exist, but file is not empty
[(and (directory-exists? config:program-directory)
(file-exists? config:list-file)
(not (null? config:list-file)))
@ -106,10 +107,9 @@
[list-length (sub1 (length (file:file->lines config:list-file)))])
(if (not (> args list-length))
(item-remove args)
;; Otherwise
(display-messages '(item-not-found))))]
;; If directory and file don't exist
;; If directory and file does not exist
[(and (not (directory-exists? config:program-directory))
(not (file-exists? config:list-file)))
(display-messages '(file-not-found try-init))]))