Adding some colors and a prompt
authorOlav Bakke Svendsen <mail@olavbs.no>
Tue, 10 Oct 2023 15:56:59 +0000 (17:56 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Tue, 10 Oct 2023 15:56:59 +0000 (17:56 +0200)
steam/simple-coal-feeder.lua

index f27c954c1cff3bd513975ae32376dfd3c715f569..c2d8d32f23918f0f9bb92193d548e02033d2c76d 100644 (file)
@@ -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