From 29d2bd9798e5f2bd0307dea7be246f75189c2214 Mon Sep 17 00:00:00 2001 From: osmarks Date: Tue, 31 Jul 2018 13:02:45 +0100 Subject: [PATCH] Initial barebones client --- client.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ installer.lua | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 client.lua 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 = {...}