From 87a1082c03d97d670051d02853528edc554f84b4 Mon Sep 17 00:00:00 2001 From: Robin Ekman Date: Tue, 20 Jan 2026 23:17:28 +0100 Subject: [PATCH] labels: simplify completion for labels --- stig/commands/base/torrent.py | 5 ++--- stig/completion/candidates.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/stig/commands/base/torrent.py b/stig/commands/base/torrent.py index 3c2d7ea1..752145e8 100644 --- a/stig/commands/base/torrent.py +++ b/stig/commands/base/torrent.py @@ -86,8 +86,7 @@ def completion_candidates_params(cls, option, args): base=objects.cfg['srv.path.complete'], directories_only=True) if option == '--labels': - curlbl = args.curarg.split(',')[-1] - return candidates.labels(curlbl) + return candidates.labels() class TorrentDetailsCmdbase(mixin.get_single_torrent, metaclass=CommandMeta): @@ -621,4 +620,4 @@ def handler(tfilter, labels): def completion_candidates_posargs(cls, args): """Complete positional arguments""" curlbl = args.curarg.split(',')[-1] - return candidates.labels(curlbl) + return candidates.labels() diff --git a/stig/completion/candidates.py b/stig/completion/candidates.py index 1b90977b..4ee89a86 100644 --- a/stig/completion/candidates.py +++ b/stig/completion/candidates.py @@ -371,16 +371,14 @@ async def objects_getter(**_): objects_getter=objects_getter, items_getter=None, filter_names=filter_names) -async def labels(curarg): +async def labels(): """All labels""" labels = set() - if curarg != "": - response = await objects.srvapi.torrent.torrents(None, ('labels', ), from_cache=True) - [ - [labels.add(l) for l in t["labels"] if l.startswith(curarg)] - for t in response.torrents - ] - return Candidates(list(labels), label=curarg, curarg_seps=',') + response = await objects.srvapi.torrent.torrents(None, ('labels', ), from_cache=True) + [ + [labels.add(l) for l in t["labels"]] for t in response.torrents + ] + return Candidates(list(labels), label="Labels", curarg_seps=',') async def _filter(curarg, filter_cls_name, objects_getter, items_getter, filter_names):