From: plugd Date: Fri, 2 Aug 2024 04:00:44 +0000 (+0200) Subject: Config loading working. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=db8d5761fd77575b5f4a011c831285f05a31d268;p=qwikboard.git Config loading working. --- diff --git a/obbs b/obbs index 97473d7..f5b7191 100755 --- a/obbs +++ b/obbs @@ -9,7 +9,16 @@ Here COMMAND is one of: You can also use the -c option to specify an alternative configuration file. (The default is the file "config.lua" in the current directory.)]] +obbs = {} +local config_file = "config.lua" +local function load_config () + io.write("Loading config from file '" .. config_file .. "'... ") + dofile(config_file) + print("done.") +end + local cmd = {} + function cmd.newcfg () print [[ --- OBBS Configuration File @@ -23,25 +32,33 @@ obbs.conferences = { "Meta" } ]] - end -local conf = {} -local function load_config (file) - - loadfile(file) +function cmd.init () + load_config() + for k,v in pairs(obbs) do + print(k .. "=" .. tostring(v)) + end end -- Main local function main() + if #arg > 2 and arg[1]=="-c" then + config_file = arg[2] + table.remove(arg, 1) + table.remove(arg, 1) + end + if #arg < 1 then print(usage) else if cmd[arg[1]] then - cmd[arg[1]]() + local f = cmd[arg[1]] + table.remove(arg,1) + f() else print("Unknown command '" .. arg[1] .. "'") print(usage)