ldoc
ldoc copied to clipboard
Add "import" Function and "UNSAFE_NO_SANDBOX" Flag for Accessing Built-in Lua Objects & Functions
Hoping this is a more acceptable solution than #308.
This adds an import function which is enabled with the UNSAFE_NO_SANDBOX command line flag & is used to access built-in Lua objects & functions within the config.ld file.
Example config.ld:
local print = import("print")
local string = import("string")
for _, s in ipairs({string.split("Hello world!")}) do
print(s)
end
project = "foo"
title = "Bar"
file = {"init.lua"}
Example execution:
ldoc --UNSAFE_NO_SANDBOX .
Is it necessary to make the flag SCREAM_CASE? I have never seen it used in command arguments. --disable_sandbox fits the current naming scheme and looks better.
I would be okay dropping the use of SCREAM_CASE, but I think we should keep the urgent verbose tone with the words "unsafe" and a negative "no", so --unsafe_no_sandbox. The only other alternative might be to split this into two flags and require both, e.g. --no-sandbox, but require a --unsafe flag to enable unsafe feature(s). If we think there might be more than one we want to warn about like this perhaps that would be best.
Changed UNSAFE_NO_SANDBOX to unsafe_no_sandbox.