created a show-list function. it's ugly though
parent
d769db8737
commit
c7beb0dfd0
31
rodo.rkt
31
rodo.rkt
|
@ -2,7 +2,8 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require racket/vector
|
(require racket/vector
|
||||||
racket/file)
|
racket/file
|
||||||
|
racket/string)
|
||||||
|
|
||||||
(define program-name "rodo")
|
(define program-name "rodo")
|
||||||
(define program-directory ".rodo/")
|
(define program-directory ".rodo/")
|
||||||
|
@ -117,8 +118,28 @@
|
||||||
'no
|
'no
|
||||||
'("no" "No" "n" "N")))
|
'("no" "No" "n" "N")))
|
||||||
|
|
||||||
|
(define (show-list)
|
||||||
|
(let ([path
|
||||||
|
(expand-user-path
|
||||||
|
(string-append
|
||||||
|
program-path
|
||||||
|
program-directory
|
||||||
|
program-file))])
|
||||||
|
(let ([todo-items
|
||||||
|
(file->lines path
|
||||||
|
#:mode 'text
|
||||||
|
#:line-mode 'linefeed)])
|
||||||
|
(display
|
||||||
|
(string-join
|
||||||
|
(map (lambda (lst)
|
||||||
|
(string-append
|
||||||
|
bullet
|
||||||
|
" "
|
||||||
|
lst))
|
||||||
|
todo-items) "\n")))))
|
||||||
|
|
||||||
(define (add-item-to-file item)
|
(define (add-item-to-file item)
|
||||||
(let ([item (string-append bullet " " item "\n")])
|
(let ([item (string-append item "\n")])
|
||||||
(let
|
(let
|
||||||
([path
|
([path
|
||||||
(expand-user-path
|
(expand-user-path
|
||||||
|
@ -168,7 +189,7 @@
|
||||||
program-path
|
program-path
|
||||||
program-directory))))
|
program-directory))))
|
||||||
|
|
||||||
(define (prompt-user-init hash-list key)
|
(define (init-prompt hash-list key)
|
||||||
(d-hash-ref hash-list key)
|
(d-hash-ref hash-list key)
|
||||||
(display "> ")
|
(display "> ")
|
||||||
(let
|
(let
|
||||||
|
@ -190,7 +211,7 @@
|
||||||
(d-hash-ref messages 'terminating)]
|
(d-hash-ref messages 'terminating)]
|
||||||
|
|
||||||
[else
|
[else
|
||||||
(prompt-user-init messages 'choose-y/n)])))
|
(init-prompt messages 'choose-y/n)])))
|
||||||
|
|
||||||
(define (add-item args)
|
(define (add-item args)
|
||||||
(if
|
(if
|
||||||
|
@ -246,7 +267,7 @@
|
||||||
(if (check-for-file)
|
(if (check-for-file)
|
||||||
(d-hash-ref messages 'file-already-exists)
|
(d-hash-ref messages 'file-already-exists)
|
||||||
(begin
|
(begin
|
||||||
(prompt-user-init messages 'init-y/n))))
|
(init-prompt messages 'init-y/n))))
|
||||||
|
|
||||||
(define (main)
|
(define (main)
|
||||||
(check-args (current-command-line-arguments)))
|
(check-args (current-command-line-arguments)))
|
||||||
|
|
Loading…
Reference in New Issue