home · contact · privacy
For .cmd__connect allow fall-back to default values on most args.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 5 Aug 2025 02:44:50 +0000 (04:44 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 5 Aug 2025 02:44:50 +0000 (04:44 +0200)
ircplom/client_tui.py

index b1243eb6c0647a8d61f67387c31a79bc00e53d15..f37da99ac41fc42b749f7de9b899cd312bb08349 100644 (file)
@@ -1,6 +1,7 @@
 'TUI adaptions to Client.'
 # built-ins
 from dataclasses import dataclass
+from getpass import getuser
 # ourselves
 from ircplom.events import PayloadMixin
 from ircplom.tui_base import (BaseTui, PromptWidget, TuiEvent, Window,
@@ -39,6 +40,7 @@ class _ClientWindow(Window, ClientQueueMixin):
     prompt: _ClientPromptWidget
 
     def __init__(self, client_id: str, chat: str = '', **kwargs) -> None:
+        self._parent = parent
         self.client_id = client_id
         self.chat = chat
         super().__init__(**kwargs)
@@ -123,7 +125,10 @@ class ClientTui(BaseTui):
             client_wins[0].prompt.prefix_copy_to(win.prompt)
         return win
 
-    def cmd__connect(self, host_port: str, nickname_pw: str, realname: str
+    def cmd__connect(self,
+                     host_port: str,
+                     nickname_pw: str = '',
+                     realname: str = ''
                      ) -> None:
         'Create Client and pass it via NewClientEvent.'
         split = host_port.split(':', maxsplit=1)
@@ -140,8 +145,10 @@ class ClientTui(BaseTui):
                 self.log.alert(f'invalid port number: {to_int}')
                 return
         split = nickname_pw.split(':', maxsplit=1)
-        nickname = split[0]
+        nickname = split[0] if nickname_pw else getuser()
         password = split[1] if len(split) > 1 else ''
+        if not realname:
+            realname = nickname
         self._put(NewClientEvent(
             _ClientKnowingTui(
                 q_out=self.q_out,