Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- core = {}
- core.update = function (test)
- return 'update: ' .. test
- end
- core.install = function()
- print('install')
- end
- local cli = {
- ["update"] = { [1] = ""; usage = ""};
- ["install"] = { [1] = ""; usage = ""};
- validate = function(self, cmd, ...)
- if #arg < #self[cmd] then
- error({code = 100; message = "Not enough arguments."})
- end
- return true
- end;
- info = function(self, cmd, ...)
- local func = nil
- status, err = pcall(self.validate, self, cmd, unpack(arg or {}))
- if status then func = core[cmd] else func = function (...) print(err.code, err.message) end end
- return func, arg
- end;
- }
- local arg0 = 'update'
- local args = {}
- local func, args = cli:info(arg0, unpack(args))
- print(arg0, ': ', func,': ',args, ' :: ', func(unpack(args)))
- print("\ndone.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement