aboutsummaryrefslogtreecommitdiff
path: root/.mbs/bin/help.lua
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-07-19 14:10:39 -0400
committerAndrew Lee <alee14498@gmail.com>2019-07-19 14:10:39 -0400
commitfe08446d84e0aa939780ad013f0545778703da6d (patch)
treef45358ae6470dc894c41abcb278c4898c7ef1b18 /.mbs/bin/help.lua
parent21446806b264d8fd6694b1495f0c51bf24d26b35 (diff)
downloadbits-UI-fe08446d84e0aa939780ad013f0545778703da6d.tar.gz
bits-UI-fe08446d84e0aa939780ad013f0545778703da6d.tar.bz2
bits-UI-fe08446d84e0aa939780ad013f0545778703da6d.zip
MBS as default shell
Diffstat (limited to '.mbs/bin/help.lua')
-rw-r--r--.mbs/bin/help.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/.mbs/bin/help.lua b/.mbs/bin/help.lua
new file mode 100644
index 0000000..f92630f
--- /dev/null
+++ b/.mbs/bin/help.lua
@@ -0,0 +1,19 @@
+local topic = ... or "intro"
+
+if topic == "index" then
+ print("Help topics availiable:")
+ textutils.pagedTabulate(help.topics())
+else
+ local file_name = help.lookup(topic)
+ if not file_name then error("No help available", 0) end
+
+ local file = fs.open(file_name, "r")
+ -- Shouldn't happen, but nice to handle anyway
+ if not file then error("No help available", 0) end
+
+ local contents = file.readAll()
+ file.close()
+
+ local _, height = term.getCursorPos()
+ textutils.pagedPrint(contents, height - 3)
+end \ No newline at end of file