summaryrefslogtreecommitdiffstats
path: root/www
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-12-18 09:44:42 +0000
committerTed Trask <ttrask01@yahoo.com>2009-12-18 09:44:42 +0000
commitb5b8c138deb5d4b4216c9186e3d528792edc70b2 (patch)
tree9443d94bc41e0a6e4f4333a3642efa16139983bf /www
parent1b8a047f7d1c71a1efd0bd34b5f887086a857b20 (diff)
downloadacf-core-b5b8c138deb5d4b4216c9186e3d528792edc70b2.tar.bz2
acf-core-b5b8c138deb5d4b4216c9186e3d528792edc70b2.tar.xz
Made command-line client work.
Diffstat (limited to 'www')
-rw-r--r--www/Makefile2
-rw-r--r--www/cgi-bin/cli52
2 files changed, 41 insertions, 13 deletions
diff --git a/www/Makefile b/www/Makefile
index ca885c0..75453c8 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -1,6 +1,7 @@
include ../config.mk
WWW_DIST=cgi-bin/acf\
+ cgi-bin/cli\
cgi-bin/mvc.lua\
index.html\
sample.html\
@@ -36,6 +37,7 @@ install:
cp "$$i" "$$dest";\
done
chmod +x $(install_dir)/cgi-bin/acf
+ chmod +x $(install_dir)/cgi-bin/cli
.PHONY: $(phony)
diff --git a/www/cgi-bin/cli b/www/cgi-bin/cli
index 85ad41e..9e8ce02 100644
--- a/www/cgi-bin/cli
+++ b/www/cgi-bin/cli
@@ -1,22 +1,48 @@
+#!/usr/bin/lua
+if #arg == 0 then
+ print([[ACF Client interface
+
+Usage: 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:
+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
+
+local PATH = package.path
+package.path = "/usr/share/acf/www/cgi-bin/?.lua;" .. package.path
require("mvc")
+package.path = PATH
+
-- this is to get around having to store
--- -- the config file in /etc/helloworld/helloworld.conf
+-- 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)
+ENV.PATH_INFO = arg[1]
APP.clientdata = {}
-local cmd={}
-for i = 2, #arg do
- a,v = string.match(arg[i], "([^=]-)=(.*)")
- if v then
- APP.clientdata[a] = v
- else
- cmd[#cmd + 1] = a
- end
+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("", cmd[1], cmd[2] or "")
-
--- vim: set filetype=lua :
-
+APP:dispatch()