feat: new commands

Former-commit-id: 13cb46afc8f68d0c053ad02ff4426634020be0bd
This commit is contained in:
cschen 2024-09-02 11:38:29 +02:00
parent 364c01d194
commit a8b38e1307
3 changed files with 80 additions and 1 deletions

View file

@ -55,6 +55,28 @@
// "id": 'lmaaaao' // "id": 'lmaaaao'
} }
}, },
{
"caption": "Codemp: Invite To Workspace",
"command": "codemp_invite_to_workspace",
"arg": {
// "id": 'lmaaaao'
// "user": 'lupo'
}
},
{
"caption": "Codemp: Create Workspace",
"command": "codemp_create_workspace",
"arg": {
// "id": 'lmaaaao'
}
},
{
"caption": "Codemp: Delete Workspace",
"command": "codemp_delete_workspace",
"arg": {
// "id": 'lmaaaao'
}
},
{ {
"caption": "Codemp: Join Buffer", "caption": "Codemp: Join Buffer",
"command": "codemp_join_buffer", "command": "codemp_join_buffer",

View file

@ -1 +1 @@
d86401dbaaca8ebe4d8998563d9fceff4b6daac0 f0cef32c2765ba5d1bcaca6e11544caacf717006

View file

@ -276,6 +276,63 @@ class CodempLeaveWorkspaceCommand(sublime_plugin.WindowCommand):
return ActiveWorkspacesIdList() return ActiveWorkspacesIdList()
class CodempInviteToWorkspaceCommand(sublime_plugin.WindowCommand):
def is_enabled(self) -> bool:
return client.codemp is not None and len(client.all_workspaces(self.window)) > 0
def run(self, workspace_id: str, user: str):
assert client.codemp is not None
client.codemp.invite_to_workspace(workspace_id, user)
logger.debug(f"invite sent to user {user} for workspace {workspace_id}.")
def input(self, args):
if "workspace_id" not in args:
wslist = client.codemp.list_workspaces(True, False)
return SimpleListInput(
("workspace_id", wslist.wait()), ("user", "invitee's username")
)
if "user" not in args:
return SimpleTextInput(("user", "invitee's username"))
class CodempCreateWorkspaceCommand(sublime_plugin.WindowCommand):
def is_enabled(self):
return client.codemp is not None
def run(self, workspace_id: str):
assert client.codemp is not None
client.codemp.create_workspace(workspace_id)
def input(self, args):
if "workspace_id" not in args:
return SimpleTextInput(("workspace_id", "new workspace"))
class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand):
def is_enabled(self):
return client.codemp is not None and len(client.all_workspaces(self.window)) > 0
def run(self, workspace_id: str):
assert client.codemp is not None
vws = client.workspace_from_id(workspace_id)
if vws is not None:
if not sublime.ok_cancel_dialog(
"You are currently attached to '{workspace_id}'.\n\
Do you want to detach and delete it?",
ok_title="yes",
title="Delete Workspace?",
):
return
if not client.codemp.leave_workspace(workspace_id):
logger.debug("error while leaving the workspace:")
return
client.uninstall_workspace(vws)
client.codemp.delete_workspace(workspace_id)
# WORKSPACE COMMANDS # WORKSPACE COMMANDS
############################################################################# #############################################################################