fix: skip history if empty input

This commit is contained in:
2026-03-09 19:26:44 +01:00
parent 901a17b2ca
commit 2489c30b5a

View File

@@ -55,11 +55,18 @@ fn append_history(cmd: String) -> Nil {
fn repl_loop(cmds: dict.Dict(String, fn() -> Nil)) -> a { fn repl_loop(cmds: dict.Dict(String, fn() -> Nil)) -> a {
let input = get_line("repl> ") |> string.trim let input = get_line("repl> ") |> string.trim
let cmd = string.lowercase(input) let cmd = string.lowercase(input)
input |> append_history
case dict.get(cmds, cmd) { case cmd {
Ok(func) -> func() "" -> Nil
Error(_) -> io.println(input <> ": unknown command") _ -> {
input |> append_history
case dict.get(cmds, cmd) {
Ok(func) -> func()
Error(_) -> io.println(input <> ": unknown command")
}
}
} }
repl_loop(cmds) repl_loop(cmds)
} }