fix: suggest the closest system for --platform

--platform retroarch --system sony-playstaton listed the first ten systems
of the alphabet. The warning now names the closest systems and the
command that lists the platform's own, as --system alone already did.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 05:19:27 +02:00
1 parent 959934d43c
commit bc68e517cb
2 files changed
+29 -3

No files matched your search

+7 -3
View File
@@ -769,10 +769,14 @@ def generate_pack(
if sid in system_filter or _norm_system_id(sid) in norm_filter
}
if not filtered:
available = sorted(pack_systems.keys())[:10]
hint = suggest_names(
system_filter,
sorted(pack_systems),
f"--platform {platform_name} --list-systems",
)
print(
f" WARNING: no systems matched filter {system_filter} "
f"(available: {', '.join(available)})"
f" WARNING: {platform_name} has no system matching "
f"{', '.join(system_filter)}. {hint}"
)
return None
pack_systems = filtered
+22
View File
@@ -5884,5 +5884,27 @@ class InstallerJsonKindsNeverOverwriteEachOther(unittest.TestCase):
self.assertEqual(after, before)
class PlatformSystemTypoGetsTheClosestNames(unittest.TestCase):
"""--platform retroarch --system sony-playstaton listed the first ten
systems of the alphabet, 3do to coleco-colecovision."""
def test_the_hint_names_the_close_systems(self):
from scripts import generate_pack as gp
out = io.StringIO()
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp, \
contextlib.redirect_stdout(out):
result = gp.generate_pack(
"retroarch", str(ROOT / "platforms"), {"files": {}, "indexes": {}},
str(ROOT / "bios"), tmp, emulators_dir=str(ROOT / "emulators"),
system_filter=["sony-playstaton"], offline=True,
)
self.assertIsNone(result)
printed = out.getvalue()
self.assertIn("Did you mean: sony-playstation", printed)
self.assertIn("--platform retroarch --list-systems", printed)
self.assertNotIn("3do", printed)
if __name__ == "__main__":
unittest.main()