fix: skip history if empty input
This commit is contained in:
@@ -55,11 +55,18 @@ fn append_history(cmd: String) -> Nil {
|
||||
fn repl_loop(cmds: dict.Dict(String, fn() -> Nil)) -> a {
|
||||
let input = get_line("repl> ") |> string.trim
|
||||
let cmd = string.lowercase(input)
|
||||
|
||||
case cmd {
|
||||
"" -> Nil
|
||||
_ -> {
|
||||
input |> append_history
|
||||
case dict.get(cmds, cmd) {
|
||||
Ok(func) -> func()
|
||||
Error(_) -> io.println(input <> ": unknown command")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repl_loop(cmds)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user