From 8e6e9e07a1bfc633203d4595c6f4bdb928c8de8f Mon Sep 17 00:00:00 2001 From: cschen <camillo.schenone@gmail.com> Date: Sat, 15 Feb 2025 22:20:56 +0100 Subject: [PATCH] chore: greatly improved the readability of the connect input handler --- plugin/commands/client.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/plugin/commands/client.py b/plugin/commands/client.py index 64b772d..1bd3326 100644 --- a/plugin/commands/client.py +++ b/plugin/commands/client.py @@ -2,7 +2,6 @@ import sublime import sublime_plugin import logging -import random import codemp from ..core.session import session @@ -15,27 +14,19 @@ logger = logging.getLogger(__name__) class CodempConnectCommand(sublime_plugin.WindowCommand): def input(self, args): - if "server_host" not in args: - return SimpleTextInput( - ("server_host", "http://code.mp:50053"), - ("user_name", f"user-{random.random()}"), - ("password", "password?"), - ) + _args = { + "server_host": "code.mp", + "user_name": "Your username", + "password": "Your password" + } + missingargs = [(arg, _args[arg]) for arg in _args.keys() if arg not in args ] - if "user_name" not in args: - return SimpleTextInput( - ("user_name", f"user-{random.random()}"), - ("password", "password?"), - ) + if missingargs: + return SimpleTextInput(missingargs) - if "password" not in args: - return SimpleTextInput( - ("password", "password?"), - ) - def input_description(self): - return "Server host:" + return "Connect:" def run(self, server_host, user_name, password): # pyright: ignore[reportIncompatibleMethodOverride] def _(): @@ -130,7 +121,7 @@ class CodempInviteToWorkspaceCommand(sublime_plugin.WindowCommand): if "workspace_id" not in args: wslist = session.get_workspaces(owned=True, invited=False) return SimpleListInput( - ("workspace_id", wslist), ("user", "invitee's username") + [("workspace_id", wslist), ("user", "invitee's username")] ) if "user" not in args: