local M = {}
local ENV_TAG = {}
function M.build(name)
if type(name) ~= "string" then
error(string.format("sw.env: name must be string, got %s", type(name)), 2)
end
return function(spec)
if type(spec) ~= "table" then
error(string.format("sw.env '%s': spec must be a table", name), 2)
end
local context = {}
for k, v in pairs(spec) do context[k] = v end
return {
_tag = ENV_TAG,
name = name,
context = context,
}
end
end
function M.is_env(v)
return type(v) == "table" and v._tag == ENV_TAG
end
return M