diff options
author | Solderpunk <solderpunk@sdf.org> | 2018-12-08 15:10:36 +0000 |
---|---|---|
committer | Solderpunk <solderpunk@sdf.org> | 2018-12-08 15:10:36 +0000 |
commit | 74db639ba4f89c4e26e95d64659c5309002b136b (patch) | |
tree | fb87a8621488968efb6a5d126010c030a66b0a2e | |
parent | Swap usage of vars 'boards' and 'board_names' to match the uses in their decl... (diff) |
Gracefully handle empty lines.
-rwxr-xr-x | telem.lua | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -279,11 +279,13 @@ function do_type() -- Show prompt and read one char io.write("[f]irst, [n]ext, [p]rev, [l]last, [r]eply, [d]one > ") c = getchar() - io.write("\n") + if c ~= "\n" then io.write("\n") end -- Dispatch to sub-command - if type_dispatch[c] == nil then + if c == "\n" then + -- pass + elseif type_dispatch[c] == nil then print("Invalid command!") - else + elseif c ~= "\n" then type_dispatch[c]() end until c == "d" @@ -357,11 +359,13 @@ repeat -- Show prompt and read 1 char from keyboard io.write("["..current_board.."] COMMAND :> ") c = getchar() - io.write("\n") + if c ~= "\n" then io.write("\n") end -- Use char as index into dispatch table - if dispatch[c] == nil then + if c == "\n" then + -- pass + elseif dispatch[c] == nil then print("Unrecognised command, hit `h` for help.") - else + else dispatch[c]() end until c == "q" |