blob: a0560a7017178be164b3260227e1dff53388ba7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/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"
boolean parameters are true if defined, false is undefined
Example:
acf-cli acf-util/password/newuser password="test123" password_confirm="test123" roles[1]="ADMIN" userid="root" Create
For forms, remember to pass in the "option" value as a parameter (see Create in example above).
Output will be a serialized Lua table.
]])
return
end
require("posix")
mvc = require("acf.mvc")
-- this is to get around having to store
-- the config file in /etc/helloworld/helloworld.conf
ENV={}
ENV.HOME="."
FRAMEWORK=mvc:new()
FRAMEWORK:read_config("acf")
APP=FRAMEWORK:new("acf_cli")
-- command line will have URI-type string defining prefix/controller/action
-- (put into ENV.PATH_INFO)
-- followed by parameters
-- (put into APP.clientdata)
APP.clientdata = {}
for i=2,#arg do
a,v = string.match(arg[i], "([^=]*)=(.*)")
if v then
APP.clientdata[a] = v
else
APP.clientdata[arg[i]] = true
end
end
APP:dispatch(APP.parse_path_info(arg[1]))
APP:destroy()
FRAMEWORK:destroy()
|