aboutsummaryrefslogtreecommitdiff
path: root/.mbs/bin/help.lua
blob: f92630fc8717949a58073d4daf463efdd6e19eb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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