diff options
author | Steven Barth <steven@midlink.org> | 2008-07-26 22:29:09 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-07-26 22:29:09 +0000 |
commit | e8c070753409e859cfe6be04873466a9cf2fe703 (patch) | |
tree | c2f6b5d974d32e34eaeb31801f4c01f759dd0224 /libs/lpk/luasrc/lpk.lua | |
parent | f9190f89458c5603551007e827a0a13f15fb452f (diff) |
luci/lpk: Initial commit
Diffstat (limited to 'libs/lpk/luasrc/lpk.lua')
-rw-r--r-- | libs/lpk/luasrc/lpk.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libs/lpk/luasrc/lpk.lua b/libs/lpk/luasrc/lpk.lua new file mode 100644 index 0000000000..fc2235458f --- /dev/null +++ b/libs/lpk/luasrc/lpk.lua @@ -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 + |