mirror of
https://github.com/Hilbis/Hilbish
synced 2025-03-14 02:10:41 +00:00
this adds `hilbish.opts`, a table to set simple options akin to shopt or setopt on other shells. this commit specifically also includes the autocd opt, which functions the way you expect it to to set opts, simply do `hilbish.opts.name = val`, where `name` is the opt you want to set and `val` being the opt setting. ie: `hilbish.opts.autocd = true` to turn on autocd
29 lines
472 B
Lua
29 lines
472 B
Lua
local opts = {}
|
|
hilbish.opts = {}
|
|
|
|
setmetatable(hilbish.opts, {
|
|
__newindex = function(_, k, v)
|
|
if opts[k] == nil then
|
|
error(string.format('opt %s does not exist', k))
|
|
end
|
|
|
|
opts[k] = v
|
|
end,
|
|
__index = function(_, k)
|
|
return opts[k]
|
|
end
|
|
})
|
|
|
|
local function setupOpt(name, default)
|
|
opts[name] = default
|
|
require('nature.opts.' .. name)
|
|
end
|
|
|
|
local defaultOpts = {
|
|
autocd = false
|
|
}
|
|
|
|
for optsName, default in pairs(defaultOpts) do
|
|
setupOpt(optsName, default)
|
|
end
|