#!/usr/bin/env lua local usage = [[Usage: obbs [-c config_file] COMMAND [arguments ...] Here COMMAND is one of: newcfg init 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 obbs.name = "My OBBS Name" obbs.sysop = "Sysop Name" obbs.conferences = { "Announcements", "General", "Meta" } ]] end 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 local f = cmd[arg[1]] table.remove(arg,1) f() else print("Unknown command '" .. arg[1] .. "'") print(usage) end end end main() .