diff --git a/client.lua b/client.lua new file mode 100644 index 0000000..d6905c0 --- /dev/null +++ b/client.lua @@ -0,0 +1,45 @@ +local w = require "lib" +local d = require "luadash" + +local function split_at_spaces(s) + local t = {} + for i in string.gmatch(s, "%S+") do + table.insert(t, i) + end + return t +end + +local function first_letter(s) + return string.sub(s, 1, 1) +end + +local usage = [[ + Welcome to the Wyvern CLI Client, "Because Gollark Was Lazy". + All commands listed below can also be accessed using single-letter shortcuts for convenience. +]] + +local commands = { + help = function() print(usage) end +} + + +print "Wyvern CLI Client" + +while true do + write "|> " + local text = read() + local tokens = split_at_spaces(text) + local command = tokens[1] + local args = d.tail(tokens) + local fn = commands[command] + if not fn then + for command_name, func in pairs(commands) do + if first_letter(command_name) == first_letter(command) then fn = func end + end + end + if not fn then + print("Command", command, "not found.") + end + + fn(table.unpack(args)) +end \ No newline at end of file diff --git a/installer.lua b/installer.lua index 06f83cb..4dd4dfe 100644 --- a/installer.lua +++ b/installer.lua @@ -1,6 +1,6 @@ local wyvern_files = { root = "https://osmarks.tk/git/osmarks/wyvern/raw/branch/master/", - files = { "installer.lua", "luadash.lua", "lib.lua", "backend-chests.lua" } + files = { "installer.lua", "luadash.lua", "lib.lua", "backend-chests.lua", "client.lua" } } local args = {...}