summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Poslavsky <alexander.poslavsky@gmail.com>2007-11-02 14:55:11 +0000
committerAlexander Poslavsky <alexander.poslavsky@gmail.com>2007-11-02 14:55:11 +0000
commitd49ec1941b5621f47662c422c0557d62385583bd (patch)
tree200fdc67b50c9dd8edf38cce1f12c90d65659b78
parentc54a2aafc967f0e599f6dbb6e4eef0ea1cd50bd4 (diff)
downloadacf-core-d49ec1941b5621f47662c422c0557d62385583bd.tar.bz2
acf-core-d49ec1941b5621f47662c422c0557d62385583bd.tar.xz
beginning of cli wrapper
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@262 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--app/acf_cli-controller.lua60
-rw-r--r--www/cgi-bin/cli22
2 files changed, 82 insertions, 0 deletions
diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua
new file mode 100644
index 0000000..2287067
--- /dev/null
+++ b/app/acf_cli-controller.lua
@@ -0,0 +1,60 @@
+module(..., package.seeall)
+
+-- We use the parent exception handler in a last-case situation
+local parent_exception_handler
+
+mvc = {}
+mvc.on_load = function (self, parent)
+
+ -- Make sure we have some kind of sane defaults for libdir and sessiondir
+ self.conf.libdir = self.conf.libdir or ( self.conf.appdir .. "/lib/" )
+ self.conf.sessiondir = self.conf.sessiondir or "/tmp/"
+ self.conf.appuri = ""
+ self.conf.default_controller = "welcome"
+
+ parent_exception_handler = parent.exception_handler
+
+ -- this sets the package path for us and our children
+ package.path= self.conf.libdir .. "?.lua;" .. package.path
+
+ self.session = {}
+ local x=require("session")
+end
+
+mvc.pre_exec = function ()
+end
+
+mvc.post_exec = function ()
+end
+
+
+view_resolver = function(self)
+ return function (viewtable)
+ print(viewtable)
+ end
+end
+
+exception_handler = function (self, message )
+ print(message)
+end
+
+-- create a Configuration Framework Entity (cfe)
+-- returns a table with at least "value", "type", "option" and "errtxt"
+cfe = function ( optiontable )
+ optiontable = optiontable or {}
+ me = { value="",
+ type="text",
+ option="",
+ errtxt="",
+ name="" }
+ for key,value in pairs(optiontable) do
+ me[key] = value
+ end
+ return me
+end
+
+
+-- syslog something
+logit = function ( ... )
+ os.execute ( "logger \"" .. ... .. "\"" )
+end
diff --git a/www/cgi-bin/cli b/www/cgi-bin/cli
new file mode 100644
index 0000000..85ad41e
--- /dev/null
+++ b/www/cgi-bin/cli
@@ -0,0 +1,22 @@
+require("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")
+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
+end
+APP:dispatch("", cmd[1], cmd[2] or "")
+
+-- vim: set filetype=lua :
+