diff --git a/scripts/diff_truth.py b/scripts/diff_truth.py index 93309018..a9cb579b 100644 --- a/scripts/diff_truth.py +++ b/scripts/diff_truth.py @@ -182,7 +182,7 @@ def main() -> None: group.add_argument( "--all", action="store_true", help="diff all registered platforms" ) - group.add_argument("--platform", type=platform_arg, help="diff a single platform") + group.add_argument("--platform", "-p", type=platform_arg, help="diff a single platform") # One output form: --json beside --format markdown printed JSON and # dropped the markdown without a word. output = parser.add_mutually_exclusive_group() @@ -207,7 +207,7 @@ def main() -> None: help="platform YAML directory (default: %(default)s)", ) parser.add_argument( - "--target", + "--target", "-t", help="read the models generate_truth --target wrote, each under the " "target as its platform files it", ) diff --git a/scripts/export_native.py b/scripts/export_native.py index 1ccddb68..ac90473f 100644 --- a/scripts/export_native.py +++ b/scripts/export_native.py @@ -857,7 +857,7 @@ def main() -> None: ) group = parser.add_mutually_exclusive_group(required=True) group.add_argument("--all", action="store_true", help="every platform") - group.add_argument("--platform", type=platform_arg, help="a single platform") + group.add_argument("--platform", "-p", type=platform_arg, help="a single platform") parser.add_argument( "--output-dir", default="exports", help="directory the updated platform files go to (default: %(default)s)", diff --git a/scripts/generate_truth.py b/scripts/generate_truth.py index 96ecda21..f2b9ce62 100644 --- a/scripts/generate_truth.py +++ b/scripts/generate_truth.py @@ -43,7 +43,7 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace: ) group = parser.add_mutually_exclusive_group(required=True) group.add_argument("--all", action="store_true", help="all registered platforms") - group.add_argument("--platform", type=platform_arg, help="single platform name") + group.add_argument("--platform", "-p", type=platform_arg, help="single platform name") parser.add_argument( "--output-dir", default=DEFAULT_OUTPUT_DIR, diff --git a/scripts/refresh_data_dirs.py b/scripts/refresh_data_dirs.py index f1f0c4b5..e4358d84 100644 --- a/scripts/refresh_data_dirs.py +++ b/scripts/refresh_data_dirs.py @@ -576,7 +576,9 @@ def main() -> None: parser.add_argument( "--dry-run", action="store_true", help="Preview without downloading" ) - parser.add_argument("--platform", type=platform_arg, help="Only refresh entries for this platform") + parser.add_argument( + "--platform", "-p", type=platform_arg, help="Only refresh entries for this platform" + ) parser.add_argument( "--registry", default=DEFAULT_REGISTRY, help="Path to _data_dirs.yml" ) diff --git a/scripts/slots.py b/scripts/slots.py index 6a5668bc..0eedb249 100644 --- a/scripts/slots.py +++ b/scripts/slots.py @@ -897,7 +897,7 @@ def main() -> int: "the file a platform baseline would ship.", ) parser.add_argument( - "--platform", type=platform_arg, + "--platform", "-p", type=platform_arg, help="one platform instead of all", ) parser.add_argument( @@ -918,7 +918,7 @@ def main() -> int: help="with all platforms, the archived ones too (RetroPie)", ) parser.add_argument( - "--target", help="judge only the cores a hardware target builds", + "--target", "-t", help="judge only the cores a hardware target builds", ) parser.add_argument( "--strict", diff --git a/tests/test_tool_messages.py b/tests/test_tool_messages.py index 977772a3..5fcd1379 100644 --- a/tests/test_tool_messages.py +++ b/tests/test_tool_messages.py @@ -145,6 +145,33 @@ class TheVerifySummaryCountsDiscrepancies(unittest.TestCase): self.assertIn(part, message) +class OneSpellingPerOption(unittest.TestCase): + """verify.py -p batocera worked and slots.py -p batocera was refused.""" + + SHORT = {"--platform": "-p", "--target": "-t"} + # migrate.py's --target is the directory files move to, not a hardware target. + OTHER_MEANING = {("migrate.py", "--target")} + + def test_every_script_takes_the_short_forms(self): + import ast # noqa: PLC0415 + + missing = [] + for path in sorted((REPO_ROOT / "scripts").rglob("*.py")): + tree = ast.parse(path.read_text(encoding="utf-8")) + for node in ast.walk(tree): + if not (isinstance(node, ast.Call) + and getattr(node.func, "attr", None) == "add_argument"): + continue + flags = [a.value for a in node.args + if isinstance(a, ast.Constant) and isinstance(a.value, str)] + for long, short in self.SHORT.items(): + if (path.name, long) in self.OTHER_MEANING: + continue + if long in flags and short not in flags: + missing.append(f"{path.relative_to(REPO_ROOT)}:{node.lineno} {long}") + self.assertEqual(missing, []) + + class ThePipelineCountsItsRealSteps(unittest.TestCase): """Labels read N/8 for a run of 24 steps, and the summary used keys the log never printed."""