From 75e763711f50421b846fb6617a1a12c0383fb1b8 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 22 Aug 2024 03:41:46 +0200 Subject: [PATCH] feat: added start/available/invite commands --- README.md | 3 +++ src/command.lua | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/README.md b/README.md index 9abd1b3..93b0ed2 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ once connected, more commands become available: | --- | --- | | `:MP disconnect` | disconnects from server | | `:MP id` | shows current client id | +| `:MP start ` | will create a new workspace with given name | +| `:MP invite [workspace]` | invite given user to workspace | +| `:MP available` | list all workspaces available to join | | `:MP join ` | will join requested workspace; starts processing cursors, users and filetree | after a workspace is joined, more commands become available: diff --git a/src/command.lua b/src/command.lua index ba1eb6c..618d078 100644 --- a/src/command.lua +++ b/src/command.lua @@ -44,6 +44,32 @@ local connected_actions = { print(" >< joined workspace " .. ws) end, + start = function(ws) + if ws == nil then error("missing workspace name") end + state.client:create_workspace(ws):await() + print(" <> created workspace " .. ws) + end, + + available = function() + for _, ws in ipairs(state.client:list_workspaces(true, false):await()) do + print(" ++ " .. ws) + end + for _, ws in ipairs(state.client:list_workspaces(false, true):await()) do + print(" -- " .. ws) + end + end, + + invite = function(user) + local ws + if state.workspace ~= nil then + ws = state.workspace + else + ws = vim.fn.input("workspace > ", "") + end + state.client:invite_to_workspace(ws, user):await() + print(" ][ invited " .. user .. " to workspace " .. ws) + end, + disconnect = function() print(" xx disconnecting client " .. state.client.id) state.client = nil -- should drop and thus close everything