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 {
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user