mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 01:53:56 -06:00
fix: suggest the closest data directory key
This commit is contained in:
1 parent
b79e551b88
commit
0c92fb6705
2 files changed
+16
-2
No files matched your search
@@ -27,7 +27,7 @@ import zipfile
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
from artifacts import file_lock as _file_lock, set_plain_mode
|
||||
from common import github_token, platform_arg, require_platform, yaml_load
|
||||
from common import github_token, platform_arg, require_platform, suggest_names, yaml_load
|
||||
|
||||
try:
|
||||
import yaml
|
||||
@@ -607,7 +607,7 @@ def main() -> None:
|
||||
|
||||
if args.key:
|
||||
if args.key not in registry:
|
||||
log.error("unknown key: %s (available: %s)", args.key, ", ".join(registry))
|
||||
log.error("unknown key: %s. %s", args.key, suggest_names([args.key], list(registry), "--dry-run"))
|
||||
raise SystemExit(1)
|
||||
allowed = registry[args.key].get("for_platforms")
|
||||
if args.platform and allowed and args.platform not in allowed:
|
||||
|
||||
@@ -83,6 +83,20 @@ class AMistypedTargetGetsTheClosestName(unittest.TestCase):
|
||||
self.assertNotIn("board-0", message)
|
||||
|
||||
|
||||
|
||||
class AMistypedDataKeyGetsTheClosestName(unittest.TestCase):
|
||||
"""`--key dolphin-sis` printed all 27 keys on one line."""
|
||||
|
||||
def test_did_you_mean(self):
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/refresh_data_dirs.py", "--key", "dolphin-sis", "--dry-run"],
|
||||
cwd=REPO_ROOT, capture_output=True, text=True, check=False,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 1)
|
||||
self.assertIn("unknown key: dolphin-sis. Did you mean: dolphin-sys? --dry-run lists all",
|
||||
proc.stderr)
|
||||
self.assertNotIn("ppsspp-assets", proc.stderr)
|
||||
|
||||
class TheTruthDiffShowsWhereAndAsksNothing(unittest.TestCase):
|
||||
"""The markdown wrote `**Remove** hiscore.dat (phantom)` beside six
|
||||
`**Add** hiscore.dat`, none with a path, for files profiled cores read."""
|
||||
|
||||
Reference in new issue
Block a user