libs/lpk: Fixed typos
[project/luci.git] / libs / lpk / luasrc / lpk.lua
1 module("luci.lpk", package.seeall)
2 require("luci.lpk.util")
3 require("luci.lpk.core")
4
5 __appname__ = "LuCI »lpk« Package Manager"
6 __version__ = "0.1"
7 __authors__ = "Steven Barth, Jo-Philipp Wich"
8 __cpyrght__ = string.format("Copyright (c) 2008 %s", __authors__)
9  
10
11 options, arguments = luci.lpk.util.getopt(arg)
12 config  = luci.util.dtable()
13 machine = luci.lpk.core.Machine()
14
15 local cfgdump = loadfile("/etc/lpk.conf")
16 if cfgdump then
17         setfenv(cfgdump, config)
18         pcall(cfgdump)
19 end
20
21 if #arguments < 1 then
22         luci.lpk.util.splash()
23 else
24         local task, error = machine:task(table.remove(arguments, 1),
25          unpack(arguments))
26                 
27         if task then
28                 local stat, error = task:perform()
29                 if not stat then
30                         luci.util.perror(error or task.register.errstr or "Unknown Error")
31                         os.exit(task.register.error or 1)
32                 end
33         else
34                 luci.util.perror((error or "Unknown Error") .. "\n")
35                 luci.lpk.util.splash()
36                 os.exit(1)
37         end             
38 end
39
40
41