feat: added start/available/invite commands

This commit is contained in:
əlemi 2024-08-22 03:41:46 +02:00
parent 0da26b0639
commit 75e763711f
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 29 additions and 0 deletions

View file

@ -34,6 +34,9 @@ once connected, more commands become available:
| --- | --- |
| `:MP disconnect` | disconnects from server |
| `:MP id` | shows current client id |
| `:MP start <workspace>` | will create a new workspace with given name |
| `:MP invite <user> [workspace]` | invite given user to workspace |
| `:MP available` | list all workspaces available to join |
| `:MP join <workspace>` | will join requested workspace; starts processing cursors, users and filetree |
after a workspace is joined, more commands become available:

View file

@ -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