From: Christian Heller Date: Sun, 10 Aug 2025 09:25:37 +0000 (+0200) Subject: Fix command argument parser forgetting splittable last parts of last arg. X-Git-Url: https://plomlompom.com/repos/booking/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/blog?a=commitdiff_plain;h=be19a940268dbdbe00d3a4c885fd01d8692a79d2;p=ircplom Fix command argument parser forgetting splittable last parts of last arg. --- diff --git a/ircplom/tui_base.py b/ircplom/tui_base.py index 72a2247..3a9e0f4 100644 --- a/ircplom/tui_base.py +++ b/ircplom/tui_base.py @@ -476,15 +476,14 @@ class BaseTui(QueueMixin): if toks and not n_args_max: alert = f'{cmd_name} given argument(s) while none expected' else: - args: list[str] = [] - while toks and len(args) < n_args_max: - toks = toks[0].split(maxsplit=1) - args += [toks.pop(0)] - if len(args) < n_args_min: + if toks: + while ' ' in toks[-1] and len(toks) < n_args_max: + toks = toks[:-1] + toks[-1].split(maxsplit=1) + if len(toks) < n_args_min: alert = f'{cmd_name} too few arguments '\ - + f'(given {len(args)}, need {n_args_min})' + + f'(given {len(toks)}, need {n_args_min})' else: - alert = cmd(*args) + alert = cmd(*toks) else: alert = 'not prefixed by /' if alert: