From: Olav Bakke Svendsen Date: Tue, 10 Oct 2023 15:56:59 +0000 (+0200) Subject: Adding some colors and a prompt X-Git-Tag: stable-steam~40 X-Git-Url: http://git.olavbs.no/?a=commitdiff_plain;h=e5708c9ea144ba8e2069076c7c1880a765833bd5;p=cc.git Adding some colors and a prompt --- diff --git a/steam/simple-coal-feeder.lua b/steam/simple-coal-feeder.lua index f27c954..c2d8d32 100644 --- a/steam/simple-coal-feeder.lua +++ b/steam/simple-coal-feeder.lua @@ -23,11 +23,17 @@ local config_path = "simple-coal-feeder.config" local config = nil local print_help = function() - print("> start engine_name\n starts engine_name") - print("> stop engine_name\n stopts engine_name") - print("> status [engine_name]\n prints status") - print("> exit\n exits program") - print("> help, ?\n prints help") + local format = function(cmd,desc) + term.setTextColor(1) + print("> "..cmd) + term.setTextColor(256) + print(" "..desc) + end + f("start engine_name" , "starts engine_name") + f("stop engine_name" , "stopts engine_name") + f("status [engine_name]" , "prints status") + f("exit" , "exits program") + f("help, ?" , "prints help") end local start_engine = function(engine) @@ -42,6 +48,7 @@ end local main = function() local running = true + print("type \"help\" or \"?\" for help") local case = { ["test"] = function(a) print("testing, one two, one two!") @@ -63,6 +70,9 @@ local main = function() } while running do + term.setTextColor(64) + term.write("> ") + term.setTextColor(1) local cmd, arg = parse_command(read()) for c,f in pairs(case) do if cmd == c then f(arg); break end @@ -72,9 +82,11 @@ end if fs.exists(config_path) then config = dofile("simple-coal-feeder.config") + -- todo: check config validity main() else print("No configuration!") + print("See executable for help configuring") end