luci/lpk: Initial commit
This commit is contained in:
parent
f9190f8945
commit
e8c0707534
6 changed files with 65 additions and 0 deletions
2
libs/lpk/Makefile
Normal file
2
libs/lpk/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
include ../../build/config.mk
|
||||||
|
include ../../build/module.mk
|
38
libs/lpk/luasrc/lpk.lua
Normal file
38
libs/lpk/luasrc/lpk.lua
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
module("luci.lpk", package.seeall)
|
||||||
|
|
||||||
|
function getopt( arg, options )
|
||||||
|
local tab = {}
|
||||||
|
local args = {}
|
||||||
|
for k, v in ipairs(arg) do
|
||||||
|
if v:sub(1, 2) == "--" then
|
||||||
|
local x = v:find( "=", 1, true )
|
||||||
|
if x then
|
||||||
|
tab[ v:sub( 3, x-1 ) ] = v:sub( x+1 )
|
||||||
|
else
|
||||||
|
tab[ v:sub( 3 ) ] = true
|
||||||
|
end
|
||||||
|
elseif v:sub( 1, 1 ) == "-" then
|
||||||
|
local y = 2
|
||||||
|
local l = #v
|
||||||
|
local jopt
|
||||||
|
while ( y <= l ) do
|
||||||
|
jopt = v:sub( y, y )
|
||||||
|
if options:find( jopt, 1, true ) then
|
||||||
|
if y < l then
|
||||||
|
tab[ jopt ] = v:sub( y+1 )
|
||||||
|
y = l
|
||||||
|
else
|
||||||
|
tab[ jopt ] = arg[ k + 1 ]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
tab[ jopt ] = true
|
||||||
|
end
|
||||||
|
y = y + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(args, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tab, args
|
||||||
|
end
|
||||||
|
|
25
libs/lpk/luasrc/lpk/state.lua
Normal file
25
libs/lpk/luasrc/lpk/state.lua
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
module("luci.lpk.state", package.seeall)
|
||||||
|
require("luci.util")
|
||||||
|
|
||||||
|
State = luci.util.class()
|
||||||
|
|
||||||
|
function State.__init__()
|
||||||
|
self.poststates = {}
|
||||||
|
self.prestates = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function State.add_poststate(state)
|
||||||
|
table.insert(self.poststates, state)
|
||||||
|
end
|
||||||
|
|
||||||
|
function State.add_prestate(state)
|
||||||
|
table.insert(self.prestates, state)
|
||||||
|
end
|
||||||
|
|
||||||
|
function State.process()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function State.handle()
|
||||||
|
|
||||||
|
end
|
0
libs/lpk/luasrc/lpk/state/install.lua
Normal file
0
libs/lpk/luasrc/lpk/state/install.lua
Normal file
0
libs/lpk/luasrc/lpk/state/resolve.lua
Normal file
0
libs/lpk/luasrc/lpk/state/resolve.lua
Normal file
0
libs/lpk/luasrc/lpk/state/retreive.lua
Normal file
0
libs/lpk/luasrc/lpk/state/retreive.lua
Normal file
Loading…
Reference in a new issue