25 lines
418 B
Lua
25 lines
418 B
Lua
|
-- Express configuration more sussunctly
|
||
|
|
||
|
local exp = {}
|
||
|
local types = {
|
||
|
download = {},
|
||
|
immediate = {},
|
||
|
command = {},
|
||
|
}
|
||
|
|
||
|
for name, _ in pairs(types) do
|
||
|
exp[name] = function(v)
|
||
|
return {v, [types[name]] = true}
|
||
|
end
|
||
|
exp["is_" .. name] = function(tbl)
|
||
|
return tbl[types[name]]
|
||
|
end
|
||
|
end
|
||
|
|
||
|
-- Produce a string contains alfanum and underscore
|
||
|
exp.safe = function(s)
|
||
|
return s:gsub("[^A-Za-z0-9]","-")
|
||
|
end
|
||
|
|
||
|
return exp
|