summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2011-08-30 20:13:24 +0000
committerTed Trask <ttrask01@yahoo.com>2011-08-30 20:13:24 +0000
commit42750f022f4b2b9a9df6237c0981fdd479f4532d (patch)
tree219a575c980e5942c2ca9473b426caf289188e15 /bin
parent733a51c96e6b97a725afab9923efd7ef5b509e0b (diff)
downloadacf-core-42750f022f4b2b9a9df6237c0981fdd479f4532d.tar.bz2
acf-core-42750f022f4b2b9a9df6237c0981fdd479f4532d.tar.xz
Moved mvc.lua into /usr/share/lua and cli to /usr/bin/acf_cli
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile36
-rwxr-xr-xbin/acf_cli53
2 files changed, 89 insertions, 0 deletions
diff --git a/bin/Makefile b/bin/Makefile
new file mode 100644
index 0000000..77158af
--- /dev/null
+++ b/bin/Makefile
@@ -0,0 +1,36 @@
+include ../config.mk
+
+BIN_DIST=acf_cli\
+
+EXTRA_DIST=Makefile
+DISTFILES=$(BIN_DIST) $(EXTRA_DIST)
+
+install_dir=$(DESTDIR)/$(bindir)
+dist_dir=$(DISTDIR)/$(notdir $(PWD))
+
+phony+=all
+all:
+
+phony+=clean
+clean:
+
+phony+=distdir
+distdir: $(DISTFILES)
+ mkdir -p "$(dist_dir)"
+ for i in $(DISTFILES); do\
+ dest=`dirname "$(dist_dir)/$$i"`;\
+ mkdir -p "$$dest";\
+ cp "$$i" "$$dest";\
+ done
+
+phony+=install
+install:
+ mkdir -p $(install_dir)
+ for i in $(BIN_DIST); do\
+ dest=`dirname "$(install_dir)/$$i"`;\
+ mkdir -p "$$dest";\
+ cp "$$i" "$$dest";\
+ done
+ chmod 700 $(install_dir)/acf_cli
+
+.PHONY: $(phony)
diff --git a/bin/acf_cli b/bin/acf_cli
new file mode 100755
index 0000000..4ef512e
--- /dev/null
+++ b/bin/acf_cli
@@ -0,0 +1,53 @@
+#!/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")
+--local PATH = package.path
+--local p = posix.dirname(arg[0])
+--if p:sub(1,1) ~= "/" then p = posix.getcwd().."/"..p end
+--package.path = p.."/?.lua;" .. package.path
+mvc = require("acf.mvc")
+--package.path = PATH
+
+-- 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)
+ENV.PATH_INFO = arg[1]
+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:destroy()
+FRAMEWORK:destroy()