1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 18:18:51 +03:00
mal/io/MalReadline.io
2016-03-07 08:55:12 -05:00

20 lines
562 B
Io

MalReadline := Object clone do (
historyLoaded := false
historyFile := (System getEnvironmentVariable("HOME")) .. "/.mal-history"
loadHistory := method(
if(File exists(historyFile), ReadLine loadHistory(historyFile))
historyLoaded = true
)
readLine := method(prompt,
if(historyLoaded not, loadHistory)
line := ReadLine readLine(prompt)
if(line isNil, return(nil))
if(line isEmpty, return(line))
ReadLine addHistory(line)
ReadLine saveHistory(historyFile)
line
)
)