docs: add emmylua doc for functions

runners
TorchedSammy 2022-05-28 18:55:18 -04:00
parent 180b77f166
commit 1c4f4b52f3
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,9 @@ local currentRunner = 'hybrid'
local runnerHandler = {} local runnerHandler = {}
local runners = {} local runners = {}
--- Get a runner by name.
--- @param name string
--- @return table
function runnerHandler.get(name) function runnerHandler.get(name)
local r = runners[name] local r = runners[name]
@ -12,6 +15,10 @@ function runnerHandler.get(name)
return r return r
end end
--- Adds a runner to the table of available runners. If runner is a table,
--- it must have the run function in it.
--- @param name string
--- @param runner function | table
function runnerHandler.add(name, runner) function runnerHandler.add(name, runner)
if type(name) ~= 'string' then if type(name) ~= 'string' then
error 'expected runner name to be a table' error 'expected runner name to be a table'
@ -32,6 +39,9 @@ function runnerHandler.add(name, runner)
runnerHandler.set(name, runner) runnerHandler.set(name, runner)
end end
--- Sets a runner by name. The runner table must have the run function in it.
--- @param name string
--- @param runner table
function runnerHandler.set(name, runner) function runnerHandler.set(name, runner)
if not runner.run or type(runner.run) ~= 'function' then if not runner.run or type(runner.run) ~= 'function' then
error 'run function in runner missing' error 'run function in runner missing'
@ -40,6 +50,11 @@ function runnerHandler.set(name, runner)
runners[name] = runner runners[name] = runner
end end
--- Executes cmd with a runner. If runnerName isn't passed, it uses
--- the user's current runner.
--- @param cmd string
--- @param runnerName string?
--- @return string, number, string
function runnerHandler.exec(cmd, runnerName) function runnerHandler.exec(cmd, runnerName)
if not runnerName then runnerName = currentRunner end if not runnerName then runnerName = currentRunner end
@ -50,6 +65,8 @@ end
-- lsp shut up -- lsp shut up
hilbish = hilbish hilbish = hilbish
--- Sets the current interactive/command line runner mode.
--- @param name string
function runnerHandler.setCurrent(name) function runnerHandler.setCurrent(name)
local r = runnerHandler.get(name) local r = runnerHandler.get(name)
currentRunner = name currentRunner = name