initial commit

master
Josha von Gizycki 5 years ago
parent 5a24609498
commit 585aafd306

2
.gitignore vendored

@ -1 +1,3 @@
*.*~
build
dorodata

@ -1,4 +1,110 @@
(print "build time")
(def logo
`
▓█████▄ ▒█████ ██▀███ ▒█████
▒██▀ ██▌▒██▒ ██▒▓██ ▒ ██▒▒██▒ ██▒
░██ █▌▒██░ ██▒▓██ ░▄█ ▒▒██░ ██▒
░▓█▄ ▌▒██ ██░▒██▀▀█▄ ▒██ ██░
░▒████▓ ░ ████▓▒░░██▓ ▒██▒░ ████▓▒░
▒▒▓ ▒ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░ ▒░▒░▒░
░ ▒ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ▒ ▒░
░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ▒
░ ░ ░ ░ ░ ░
`)
(def bye
`
▄▄▄▄ ▓██ ██▓▓█████
▓█████▄▒██ ██▒▓█ ▀
▒██▒ ▄██▒██ ██░▒███
▒██░█▀ ░ ▐██▓░▒▓█ ▄
░▓█ ▀█▓░ ██▒▓░░▒████▒
░▒▓███▀▒ ██▒▒▒ ░░ ▒░ ░
▒░▒ ░▓██ ░▒░ ░ ░ ░
░ ░▒ ▒ ░░ ░
░ ░ ░ ░ ░
░░ ░
`)
(def dorodata "dorodata")
(defn help []
(print "add, rm, mod, help, quit, [enter]"))
(defn readline []
(let [line (file/read stdin :line)]
(if (nil? line)
nil
(string/trimr line))))
(defn quit []
(print bye)
(os/exit 0))
(defn lines->entries [lines]
(var entries @[])
(loop [line :in lines]
(let [[key content] (string/split ":" line)
kwkey (keyword key)]
(when (or (= "id" key)
(nil? (array/peek entries)))
(array/push entries @{}))
(set ((array/peek entries) kwkey)
content)))
entries)
(defn ensure-dorodata []
(-> (file/open dorodata :w)
(file/flush)
(file/close)))
(defn load-entries []
(let [f (file/open dorodata :r)
content (file/read f :all)]
(file/close f)
(->> content
(string/split "\n")
lines->entries)))
(defn entries->string [entries]
(reduce (fn [acc entry]
(string acc
"id:" (entry :id) "\n"
"title:" (entry :title) "\n"))
""
entries))
(defn save-entries [entries]
(let [f (file/open dorodata :w)]
(file/write f (entries->string entries))
(file/flush f)
(file/close f)))
(defn request-val [label]
(print label)
(readline))
(defn new-id []
(inc (max ;(map (fn [e] (scan-number (e :id)))
(load-entries)))))
(defn add []
(-> (load-entries)
(array/push {:id (new-id)
:title (request-val "Title")})
save-entries))
(def structure
{"add" add
"rm" (fn [] (print "rm"))
"mod" (fn [] (print "mod"))
"help" help
"" (fn [] (print "overview"))
"quit" quit})
(defn main [& args]
(print "hello world"))
(ensure-dorodata)
(print logo)
(help)
(while true
((get structure (readline) help))))

@ -1,3 +1,7 @@
(declare-project
:name "doro"
:description "pomodoro style task tracker")
(declare-executable
:name "doro"
:entry "main.janet")

Loading…
Cancel
Save