-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config file #16
Comments
…t handling This is a preparation for #16. Doing this refactor I learnt that cluttex (and thus also cluttealtex) parses arguments which have a default value quite weird. If default is set and parameter is specified as --opt=param, the parameter from the argument is taken. If default is set and parameter is specified as --opt param, the default paramter is taken and the cli parameter is ignored (probably produces an error later during parsing). The main part of the refactor was 1. move the option_spec to its own file 2. move handling the options inside the option_spec table 3. generate LUT to avoid having to iterate over the complete table Now when adding a new option all that needs to be done is in the option_spec.lua file (adding the entry in the table and appending to the usage output).
Maybe the config file could even define new cli arguments (e.g. to define abbreviations like |
One idea to read in the config file/script: -- Parse options from config file
if fsutil.isfile(".cluttealtexrc.lua") then
-- see https://ref.coddy.tech/lua/lua-sandboxing
-- for us the main purpose is to avoid the config modifies the
-- environment we're working in.
-- Apart from that restriction, the config is allowed to execute
-- anything.
-- local sandbox = {
-- print = print,
-- -- Add other functions here
-- }
-- setmetatable(sandbox, {__index = function(t:table, k:any)
-- return error("Forbidden function/variable", 2) -- TODO deep-copy from _G on demand instead
-- end})
-- TODO move to a lua file to make use of _G (dynamically copy over/return on __index)
local cfgChunk, err = loadfile(".cluttealtexrc.lua")
if err then
message.error("Error loading the config file '.cluttealtexrc.lua'")
error(err)
end
local cfg: table
do
cfg = cfgChunk() as table
end
print(cfg.options)
print(cfg.defaults)
end the goal eventually is to sandbox reading the config as much as possible. For now as a proof of concept, I'd say we keep it in the global state and avoid splitting into a new |
Question: How to handle all the watch related stuff. Via cli, the order is important but via cfg it's a table without strict ordering -> leads to non-determinism 👎
|
Also |
Add the functionality to read options from a config file instead of/before reading CLI arguments.
Combined with #15 we could decide to allow (or even force) for the installation of hooks via this config file by requiring the config file being a lua script (similar to l3build.
Remember: Some options can be passed more than once and accumulate in the process (e.g. glossaries I think) in the config file we'd need to make these an array.
The text was updated successfully, but these errors were encountered: