diff options
Diffstat (limited to 'src/argent.c')
-rw-r--r-- | src/argent.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/argent.c b/src/argent.c index f057380..fb0d37b 100644 --- a/src/argent.c +++ b/src/argent.c @@ -36,6 +36,9 @@ int main(int argc, char **argv) argent_log(INFO, "log level: %s", level_string(argent_log_level)); argent_log(INFO, "configuration file: %s", opts.conf_filename); + if (opts.script_filename != NULL) { + argent_log(INFO, "script override: %s", opts.script_filename); + } argent_log(DEBUG, "create lua state"); lua_State *L = luaL_newstate(); @@ -55,8 +58,18 @@ int main(int argc, char **argv) // load argent lua script argent_log(DEBUG, "load main lua script"); - error = luaL_dostring(L, argent_script); - CHECK_LUA_ERROR(); + if (opts.script_filename == NULL) { + error = luaL_dostring(L, argent_script); + CHECK_LUA_ERROR(); + } + else { + error = luaL_dofile(L, opts.script_filename); + CHECK_LUA_ERROR(); + if (!lua_isfunction(L, -1)) { + argent_log(FATAL, "override script '%s' did not return a function!", opts.script_filename); + return 1; + } + } // load configuration file argent_log(DEBUG, "load configuration file"); |