__version__ = "0.1"
__authors__ = "Steven Barth, Jo-Philipp Wich"
__cpyrght__ = string.format("Copyright (c) 2008 %s", __authors__)
-__welcome__ = string.format("%s v%s\n%s",
- __appname__, __version__, __cpyrght__)
options, arguments = luci.lpk.util.getopt(arg)
-config = luci.util.dtable()
+config = luci.util.dtable()
+machine = luci.lpk.core.Machine()
local cfgdump = loadfile("/etc/lpk.conf")
if cfgdump then
end
if #arguments < 1 then
- print(__welcome__)
- print([[
-
-Usage:
- lpk [options] <command> [arguments]
- lpk [options] install|remove pkg1 [pkg2] [...] [pkgn]
-
-Commands:
- install - Install packages
- remove - Remove packages
- purge - Remove packages and their configuration files
-
-Options:
- --force-depends - Ignore unresolvable dependencies
-]])
+ luci.lpk.util.splash()
else
- -- Start machine
+ local task, error = machine:task(table.remove(arguments, 1),
+ unpack(arguments))
+
+ if task then
+ local stat, error = task:perform()
+ if not stat then
+ luci.util.perror(error or task.register.errstr or "Unknown Error")
+ os.exit(task.register.error or 1)
+ end
+ else
+ luci.util.perror(error .. "\n")
+ luci.lpk.util.splash()
+ os.exit(1)
+ end
end