mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2025-03-29 21:01:34 +01:00
chore: greatly improved the readability of the connect input handler
This commit is contained in:
parent
fb10452bc0
commit
8e6e9e07a1
1 changed files with 10 additions and 19 deletions
|
@ -2,7 +2,6 @@ import sublime
|
||||||
import sublime_plugin
|
import sublime_plugin
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import random
|
|
||||||
|
|
||||||
import codemp
|
import codemp
|
||||||
from ..core.session import session
|
from ..core.session import session
|
||||||
|
@ -15,27 +14,19 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class CodempConnectCommand(sublime_plugin.WindowCommand):
|
class CodempConnectCommand(sublime_plugin.WindowCommand):
|
||||||
def input(self, args):
|
def input(self, args):
|
||||||
if "server_host" not in args:
|
_args = {
|
||||||
return SimpleTextInput(
|
"server_host": "code.mp",
|
||||||
("server_host", "http://code.mp:50053"),
|
"user_name": "Your username",
|
||||||
("user_name", f"user-{random.random()}"),
|
"password": "Your password"
|
||||||
("password", "password?"),
|
}
|
||||||
)
|
missingargs = [(arg, _args[arg]) for arg in _args.keys() if arg not in args ]
|
||||||
|
|
||||||
if "user_name" not in args:
|
if missingargs:
|
||||||
return SimpleTextInput(
|
return SimpleTextInput(missingargs)
|
||||||
("user_name", f"user-{random.random()}"),
|
|
||||||
("password", "password?"),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if "password" not in args:
|
|
||||||
return SimpleTextInput(
|
|
||||||
("password", "password?"),
|
|
||||||
)
|
|
||||||
|
|
||||||
def input_description(self):
|
def input_description(self):
|
||||||
return "Server host:"
|
return "Connect:"
|
||||||
|
|
||||||
def run(self, server_host, user_name, password): # pyright: ignore[reportIncompatibleMethodOverride]
|
def run(self, server_host, user_name, password): # pyright: ignore[reportIncompatibleMethodOverride]
|
||||||
def _():
|
def _():
|
||||||
|
@ -130,7 +121,7 @@ class CodempInviteToWorkspaceCommand(sublime_plugin.WindowCommand):
|
||||||
if "workspace_id" not in args:
|
if "workspace_id" not in args:
|
||||||
wslist = session.get_workspaces(owned=True, invited=False)
|
wslist = session.get_workspaces(owned=True, invited=False)
|
||||||
return SimpleListInput(
|
return SimpleListInput(
|
||||||
("workspace_id", wslist), ("user", "invitee's username")
|
[("workspace_id", wslist), ("user", "invitee's username")]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "user" not in args:
|
if "user" not in args:
|
||||||
|
|
Loading…
Add table
Reference in a new issue