#!/usr/bin/lua if #arg == 0 then print([[ACF Client interface Usage: acf-cli [action] [parameter]... Actions are of the form "prefix/controller/action" Parameters are of the form "parameter=value" list and multi select parameters are of the form "parameter[1]=value" to set a list or multi to blank use "parameter" without any value parameters within groups are of the form "group.parameter=value" boolean parameters should be specified as "true" or "false" Example: acf-cli acf-util/password/newuser password="test123" password_confirm="test123" roles[1]="ADMIN" userid="root" submit="Create" For forms, remember to pass in "submit" as a parameter with an appropriate value from the form "option" (see Create in example above). Output will be a serialized Lua table unless specified otherwise with "viewtype" parameter. ]]) return end require("posix") mvc = require("acf.mvc") FRAMEWORK=mvc:new() FRAMEWORK:read_config("acf") APP=FRAMEWORK:new("acf_cli") -- command line will have URI-type string defining prefix/controller/action -- followed by parameters local p,c,a = APP.parse_path_info(arg[1]) local clientdata = {} for i=2,#arg do local a,v = string.match(arg[i], "([^=]*)=(.*)") if v then clientdata[a] = v else clientdata[arg[i]] = true end end APP:dispatch(p,c,a,clientdata) APP:destroy() FRAMEWORK:destroy()