cleaning up comments

main
m455 2019-06-03 22:01:34 -04:00
parent 224b9b85b3
commit 221c5bb8a4
2 changed files with 33 additions and 40 deletions

View File

@ -8,24 +8,24 @@ A easy-to-use todo list program for people who live on the command line
# Table of Contents # Table of Contents
* [TL;DR](https://github.com/m455/rodo#tldr) - [TL;DR](#tldr)
* [New things](https://github.com/m455/rodo#new-things) - [New things](#new-things)
* [Todos](https://github.com/m455/rodo#todos) - [Todos](#todos)
* [Platforms](https://github.com/m455/rodo#platforms) - [Platforms](#platforms)
* [Requirements](https://github.com/m455/rodo#requirements) - [Requirements](#requirements)
* [Downloading Racket](https://github.com/m455/rodo#downloading-racket) - [Downloading Racket](#downloading-racket)
* [To download Racket using apt](https://github.com/m455/rodo#to-download-racket-using-apt) - [To download Racket using apt](#to-download-racket-using-apt)
* [To download Racket using pacman](https://github.com/m455/rodo#to-download-racket-using-pacman) - [To download Racket using pacman](#to-download-racket-using-pacman)
* [Downloading the rodo source code](https://github.com/m455/rodo#downloading-the-rodo-source-code) - [Downloading the rodo source code](#downloading-the-rodo-source-code)
* [To download the rodo source code](https://github.com/m455/rodo#to-download-the-rodo-source-code) - [To download the rodo source code](#to-download-the-rodo-source-code)
* [Setup](https://github.com/m455/rodo#setup) - [Setup](#setup)
* [Setting up a $PATH](https://github.com/m455/rodo#setting-up-a-path) - [Setting up a $PATH](#setting-up-a-path)
* [To set up a $PATH](https://github.com/m455/rodo#to-set-up-a-path) - [To set up a $PATH](#to-set-up-a-path)
* [Adding rodo to your $PATH](https://github.com/m455/rodo#adding-rodo-to-your-path) - [Adding rodo to your $PATH](#adding-rodo-to-your-path)
* [To add rodo to your $PATH](https://github.com/m455/rodo#to-add-rodo-to-your-path) - [To add rodo to your $PATH](#to-add-rodo-to-your-path)
* [List of commands](https://github.com/m455/rodo#list-of-commands) - [List of commands](#list-of-commands)
* [Usage examples](https://github.com/m455/rodo#usage-examples) - [Usage examples](#usage-examples)
* [Configuration](https://github.com/m455/rodo#configuring-rodo) - [Configuring `rodo`](#configuring-rodo)
# TL;DR # TL;DR

View File

@ -28,7 +28,6 @@
(define (display-hash-ref hash-list key) (define (display-hash-ref hash-list key)
(display (hash-ref hash-list key))) (display (hash-ref hash-list key)))
;; Just so I don't have to keep typing "#:mode...#:line-mode..." every time
(define (file->string-list config:path-to-file-to-file) (define (file->string-list config:path-to-file-to-file)
(let ([todo-list (file:file->lines config:path-to-file-to-file (let ([todo-list (file:file->lines config:path-to-file-to-file
#:mode 'text #:mode 'text
@ -38,13 +37,10 @@
(define (list-empty? lst) (define (list-empty? lst)
(list:empty? (file->string-list lst))) (list:empty? (file->string-list lst)))
;; Find out which item is being removed by scooping up
;; the number the user entered in the command line
;; arguments
(define (get-removed-item lst args) (define (get-removed-item lst args)
;; Subtract one from what the user chose, because they are ;; Subtract one from what the user chose, because they are
;; are actually viewing the list numbers as human numbers ;; are actually viewing the list numbers as human numbers,
;; so (actual-number +1) ;; so what they see is actual-number +1
(list-ref (file->string-list lst) (sub1 (string->number args)))) (list-ref (file->string-list lst) (sub1 (string->number args))))
(define (surround-item-in-quotation-marks args) (define (surround-item-in-quotation-marks args)
@ -56,7 +52,7 @@
(define (prefix-item-with-number lst) (define (prefix-item-with-number lst)
(map string-append (map string-append
;; Note: compose starts from the last element in it's ;; Note: compose starts from the last element in it's
;; list, as if it were nested, so that would be add1 here ;; list, so that would be add1 here
(map (compose prefix-item-with-period number->string add1) (map (compose prefix-item-with-period number->string add1)
(list:range (length lst))) (list:range (length lst)))
lst)) lst))
@ -87,33 +83,30 @@
(check-for-program-directory) (check-for-program-directory)
(check-for-program-file)) (check-for-program-file))
(if (if
;; If file exists, see if it's empty, if so
;; tell the user
(list-empty? config:path-to-file) (list-empty? config:path-to-file)
(display-hash-ref messages:messages 'empty-todo-list) (display-hash-ref messages:messages 'empty-todo-list)
;; If file isn't empty, display a pretty list
(display-prettified-program-file))] (display-prettified-program-file))]
;; If file doesn't exist, tell the user
[else [else
(display-hash-ref messages:messages 'file-not-found) (display-hash-ref messages:messages 'file-not-found)
(display-hash-ref messages:messages 'try-init)])) (display-hash-ref messages:messages 'try-init)]))
(define (write-item-to-program-file args) (define (write-item-to-program-file args)
;; Add item to end of list and write to file ;; Add an item to the end of a list and write to a file
(let ([new-list (append-item-to-end args config:path-to-file)]) (let ([new-list (append-item-to-end args config:path-to-file)])
(file:display-to-file (file:display-to-file
(string:string-join new-list "\n") (string:string-join new-list "\n") config:path-to-file
config:path-to-file
#:mode 'text #:mode 'text
#:exists 'truncate) #:exists 'truncate)
;; After writing to the file, tell the user what was written
(display-item-added args))) (display-item-added args)))
(define (add-item-to-list args) (define (add-item-to-list args)
(if (and (if (and (check-for-program-directory)
(check-for-program-directory) (check-for-program-file))
(check-for-program-file)) ;; The cdr here prevents the first command line argument ("add")
;; The cdr here prevents the command line argument "add" from being added to the file ;; from being added to the file
(write-item-to-program-file (string:string-join (cdr (vector->list args)))) (write-item-to-program-file (string:string-join (cdr (vector->list args))))
;; Else
(begin (begin
(display-hash-ref messages:messages 'file-not-found) (display-hash-ref messages:messages 'file-not-found)
(display-hash-ref messages:messages 'try-init)))) (display-hash-ref messages:messages 'try-init))))
@ -131,11 +124,11 @@
(define (remove-item-from-list args) (define (remove-item-from-list args)
(cond [(list-empty? config:path-to-file) (cond [(list-empty? config:path-to-file)
(display-hash-ref messages:messages 'empty-todo-list)] (display-hash-ref messages:messages 'empty-todo-list)]
[(and [(and (check-for-program-directory)
(check-for-program-directory) (check-for-program-file))
(check-for-program-file))
(remove-item-from-program-file (vector-ref args 1))] (remove-item-from-program-file (vector-ref args 1))]
[(and (not (check-for-program-directory)) (not (check-for-program-file))) [(and (not (check-for-program-directory))
(not (check-for-program-file)))
(begin (begin
(display-hash-ref messages:messages 'file-not-found) (display-hash-ref messages:messages 'file-not-found)
(display-hash-ref messages:messages 'try-init))])) (display-hash-ref messages:messages 'try-init))]))