home · contact · privacy
Strengthen pattern of commands returning strings to trigger alerts.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 6 Aug 2025 13:47:43 +0000 (15:47 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 6 Aug 2025 13:47:43 +0000 (15:47 +0200)
ircplom/client_tui.py
ircplom/tui_base.py

index af1d8be73336be8bc9de6a944f250bebdf08daf1..a9fce33c085256c4f8592cfe16b1bd22c2a75436 100644 (file)
@@ -2,6 +2,7 @@
 # built-ins
 from dataclasses import dataclass
 from getpass import getuser
+from typing import Optional
 # ourselves
 from ircplom.tui_base import (BaseTui, PromptWidget, TuiEvent, Window,
                               CMD_SHORTCUTS)
@@ -125,21 +126,19 @@ class ClientTui(BaseTui):
                      host_port: str,
                      nickname_pw: str = '',
                      realname: str = ''
-                     ) -> None:
+                     ) -> Optional[str]:
         'Create Client and pass it via NewClientEvent.'
         split = host_port.split(':', maxsplit=1)
         hostname = split[0]
         if hostname in [win.client_id for win in self._all_client_wins]:
-            self._log.alert(f'already set up connection to {hostname}')
-            return
+            return f'already set up connection to {hostname}'
         port = -1
         if len(split) > 1:
             to_int = split[1]
             if to_int.isdigit():
                 port = int(split[1])
             else:
-                self._log.alert(f'invalid port number: {to_int}')
-                return
+                return f'invalid port number: {to_int}'
         split = nickname_pw.split(':', maxsplit=1)
         nickname = split[0] if nickname_pw else getuser()
         password = split[1] if len(split) > 1 else ''
@@ -150,6 +149,7 @@ class ClientTui(BaseTui):
                 _q_out=self._q_out,
                 conn_setup=IrcConnSetup(
                     hostname, port, nickname, realname, password))))
+        return None
 
 
 @dataclass
index 204008c982d739977e99a2a8a64d525249cd50de..c5b57b29181148fcde10513ed9d7ea97d3c979f8 100644 (file)
@@ -391,7 +391,7 @@ class BaseTui(QueueMixin):
         self.window.draw()
 
     @property
-    def _commands(self) -> dict[str, tuple[Callable[..., None],
+    def _commands(self) -> dict[str, tuple[Callable[..., None | Optional[str]],
                                            int, tuple[str, ...]]]:
         cmds = {}
         method_name_prefix = 'cmd__'