Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions stig/commands/base/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
14 changes: 6 additions & 8 deletions stig/completion/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down