mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-11 04:23:47 -06:00
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:
1 parent
959934d43c
commit
bc68e517cb
2 files changed
+29
-3
No files matched your search
@@ -769,10 +769,14 @@ def generate_pack(
|
|||||||
if sid in system_filter or _norm_system_id(sid) in norm_filter
|
if sid in system_filter or _norm_system_id(sid) in norm_filter
|
||||||
}
|
}
|
||||||
if not filtered:
|
if not filtered:
|
||||||
available = sorted(pack_systems.keys())[:10]
|
hint = suggest_names(
|
||||||
|
system_filter,
|
||||||
|
sorted(pack_systems),
|
||||||
|
f"--platform {platform_name} --list-systems",
|
||||||
|
)
|
||||||
print(
|
print(
|
||||||
f" WARNING: no systems matched filter {system_filter} "
|
f" WARNING: {platform_name} has no system matching "
|
||||||
f"(available: {', '.join(available)})"
|
f"{', '.join(system_filter)}. {hint}"
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
pack_systems = filtered
|
pack_systems = filtered
|
||||||
|
|||||||
@@ -5884,5 +5884,27 @@ class InstallerJsonKindsNeverOverwriteEachOther(unittest.TestCase):
|
|||||||
self.assertEqual(after, before)
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in new issue
Block a user