This commit is contained in:
Eric Zhao 2026-03-12 10:34:02 +08:00 committed by GitHub
commit fa09b81b78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View file

@ -548,7 +548,8 @@ optional arguments:
--tsv List games in TSV format
--json List games in JSON format
--force-refresh Force a refresh of all game metadata
-s <query>, --search <query>
Filter results by title or app name (fuzzy, case-insensitive)
Command: list-files
usage: legendary list-files [-h] [--force-download] [--platform <Platform>]
@ -584,7 +585,8 @@ optional arguments:
--tsv List games in TSV format
--json List games in JSON format
--show-dirs Print installation directory in output
-s <query>, --search <query>
Filter results by title or app name (fuzzy, case-insensitive)
Command: list-saves
usage: legendary list-saves [-h] [<App Name>]

View file

@ -70,6 +70,13 @@ class LegendaryCLI:
else:
print(json.dumps(data))
@staticmethod
def _match_search(query, *fields):
"""Return True if all whitespace-separated tokens in query appear in any of the given fields (case-insensitive)."""
tokens = query.lower().split()
combined = ' '.join(f.lower() for f in fields if f)
return all(t in combined for t in tokens)
def auth(self, args):
if args.auth_delete:
self.core.lgd.invalidate_userdata()
@ -216,6 +223,9 @@ class LegendaryCLI:
dlc_list[citem_id].extend(na_dlcs[citem_id])
dlc_list[citem_id] = sorted(dlc_list[citem_id], key=lambda d: d.app_title.lower())
if args.search:
games = [g for g in games if self._match_search(args.search, g.app_title, g.app_name)]
if args.csv or args.tsv:
writer = csv.writer(stdout, dialect='excel-tab' if args.tsv else 'excel', lineterminator='\n')
writer.writerow(['App name', 'App title', 'Version', 'Is DLC'])
@ -280,6 +290,9 @@ class LegendaryCLI:
games = sorted(self.core.get_installed_list(include_dlc=True),
key=lambda x: x.title.lower())
if args.search:
games = [g for g in games if self._match_search(args.search, g.title, g.app_name)]
versions = dict()
for game in games:
try:
@ -2873,6 +2886,8 @@ def main():
list_parser.add_argument('--json', dest='json', action='store_true', help='List games in JSON format')
list_parser.add_argument('--force-refresh', dest='force_refresh', action='store_true',
help='Force a refresh of all game metadata')
list_parser.add_argument('-s', '--search', dest='search', action='store', metavar='<query>',
help='Filter results by title or app name (fuzzy, case-insensitive)')
list_installed_parser.add_argument('--check-updates', dest='check_updates', action='store_true',
help='Check for updates for installed games')
@ -2884,6 +2899,8 @@ def main():
help='List games in JSON format')
list_installed_parser.add_argument('--show-dirs', dest='include_dir', action='store_true',
help='Print installation directory in output')
list_installed_parser.add_argument('-s', '--search', dest='search', action='store', metavar='<query>',
help='Filter results by title or app name (fuzzy, case-insensitive)')
list_files_parser.add_argument('--force-download', dest='force_download', action='store_true',
help='Always download instead of using on-disk manifest')