From dfe3541f9e2a964d9a752087ab0d12b7dd0ac9f6 Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Thu, 26 Nov 2026 13:45:04 +0100 Subject: [PATCH] fix(runs): name the nullius command in each subcommand's help Usage lines and examples of workspace, runs, compare, import, standard, paths, migrate and serve named a module path or python3 -m nullius. Each parser now sets its prog, as flags and prices do. --- app/app.py | 2 +- app/nullius/compare/cli.py | 8 ++++---- app/nullius/importers/cli.py | 8 ++++---- app/nullius/migrate.py | 2 +- app/nullius/paths.py | 2 +- app/nullius/runs/cli.py | 14 +++++++------- app/nullius/standard/cli.py | 2 +- app/nullius/workspace_cli.py | 8 ++++---- app/tests/test_cli.py | 1 - app/tests/test_cli_contract.py | 2 +- app/tests/test_unified_cli.py | 11 +++++++++++ app/ui_tests/test_settings_page.py | 3 +++ 12 files changed, 38 insertions(+), 25 deletions(-) diff --git a/app/app.py b/app/app.py index 101100cb1..0445ff89c 100644 --- a/app/app.py +++ b/app/app.py @@ -47,7 +47,7 @@ def _port(value: str) -> int: def parser() -> argparse.ArgumentParser: """The command line; the server's address and port default to APP_HOST and APP_PORT (an empty one is unset), read once, here, at start.""" - ap = argparse.ArgumentParser(description="Nullius: the run behind a benchmark score.") + ap = argparse.ArgumentParser(prog="nullius serve", description="Nullius: the run behind a benchmark score.") ap.add_argument("paths", nargs="*", help="job directory (or parent) to scan") ap.add_argument("--host", default=os.environ.get("APP_HOST") or "127.0.0.1") ap.add_argument("--port", type=_port, default=os.environ.get("APP_PORT") or "5057") diff --git a/app/nullius/compare/cli.py b/app/nullius/compare/cli.py index 277a4fcca..2ebe807ca 100644 --- a/app/nullius/compare/cli.py +++ b/app/nullius/compare/cli.py @@ -34,9 +34,9 @@ EPILOG = """\ examples: - PYTHONPATH=app python3 -m nullius.compare.cli jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 - PYTHONPATH=app python3 -m nullius.compare.cli jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 --matched - PYTHONPATH=app python3 -m nullius.compare.cli jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 --json + nullius compare jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 + nullius compare jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 --matched + nullius compare jobs 2026-09-12__22-53-55 2026-09-13__09-10-11 --json exit codes: 0 done @@ -212,7 +212,7 @@ def _emit(doc) -> None: def main(argv=None) -> int: ap = argparse.ArgumentParser( - prog="python3 -m nullius.compare.cli", description=__doc__.splitlines()[0], + prog="nullius compare", description=__doc__.splitlines()[0], epilog=EPILOG, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("root", metavar="ROOT", help="the root the jobs are under") ap.add_argument("job_ids", metavar="JOB_ID", nargs="+", diff --git a/app/nullius/importers/cli.py b/app/nullius/importers/cli.py index 9a74dece2..ad2042a6d 100755 --- a/app/nullius/importers/cli.py +++ b/app/nullius/importers/cli.py @@ -31,9 +31,9 @@ EPILOG = """\ examples: - PYTHONPATH=app python3 -m nullius.importers.cli /path/to/logs -o jobs_imported - PYTHONPATH=app python3 -m nullius.importers.cli /path/to/logs -o jobs_imported --json - PYTHONPATH=app python3 -m nullius.importers.cli --list + nullius import /path/to/logs -o jobs_imported + nullius import /path/to/logs -o jobs_imported --json + nullius import --list exit codes: 0 done @@ -47,7 +47,7 @@ def main(argv=None) -> int: ap = argparse.ArgumentParser( - prog="python3 -m nullius.importers.cli", description=__doc__.splitlines()[0], + prog="nullius import", description=__doc__.splitlines()[0], epilog=EPILOG, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("run_dir", nargs="?", help="the harness's run tree") ap.add_argument("-o", "--out", default="jobs_imported", diff --git a/app/nullius/migrate.py b/app/nullius/migrate.py index 5def150fa..b96505976 100644 --- a/app/nullius/migrate.py +++ b/app/nullius/migrate.py @@ -269,7 +269,7 @@ def migrate_providers(apply_it: bool) -> int: def main(argv=None) -> int: - parser = argparse.ArgumentParser(description="Copy legacy settings, custom catalogue entries and workspaces; preview by default.") + parser = argparse.ArgumentParser(prog="nullius migrate", description="Copy legacy settings, custom catalogue entries and workspaces; preview by default.") parser.add_argument("--from", dest="checkout", type=Path, help="existing Nullius checkout (left unchanged)") parser.add_argument("--secrets", type=Path, help="also copy a legacy benchmark licence directory") parser.add_argument("--providers", action="store_true", diff --git a/app/nullius/paths.py b/app/nullius/paths.py index 349efdbdb..f24739850 100644 --- a/app/nullius/paths.py +++ b/app/nullius/paths.py @@ -82,7 +82,7 @@ def secrets_dir(env=None) -> str: def main(argv=None) -> int: - parser = argparse.ArgumentParser(description="Show Nullius's persistent user directories (no secret values).") + parser = argparse.ArgumentParser(prog="nullius paths", description="Show Nullius's persistent user directories (no secret values).") parser.add_argument("--json", action="store_true") args = parser.parse_args(argv) values = {"settings": settings_file(), "secrets": secrets_dir(), "prices": prices_file(), "own prices": own_prices_file(), "catalogue": catalogue_dir(), diff --git a/app/nullius/runs/cli.py b/app/nullius/runs/cli.py index 48646b7a0..5e241645f 100644 --- a/app/nullius/runs/cli.py +++ b/app/nullius/runs/cli.py @@ -49,12 +49,12 @@ EPILOG = """\ examples: - PYTHONPATH=app python3 -m nullius.runs.cli list jobs - PYTHONPATH=app python3 -m nullius.runs.cli list jobs jobs_imported --json - PYTHONPATH=app python3 -m nullius.runs.cli show jobs 2026-09-12__22-53-55 --json - PYTHONPATH=app python3 -m nullius.runs.cli show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq - PYTHONPATH=app python3 -m nullius.runs.cli show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq --call 3 --request - PYTHONPATH=app python3 -m nullius.runs.cli show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq --calls + nullius runs list jobs + nullius runs list jobs jobs_imported --json + nullius runs show jobs 2026-09-12__22-53-55 --json + nullius runs show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq + nullius runs show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq --call 3 --request + nullius runs show jobs 2026-09-12__22-53-55 astropy__astropy-8707__agWFDYq --calls exit codes: 0 done @@ -339,7 +339,7 @@ def _show(args) -> int: def main(argv=None) -> int: ap = argparse.ArgumentParser( - prog="python3 -m nullius.runs.cli", description=__doc__.splitlines()[0], + prog="nullius runs", description=__doc__.splitlines()[0], epilog=EPILOG, formatter_class=argparse.RawDescriptionHelpFormatter) sub = ap.add_subparsers(dest="command", metavar="COMMAND") ls = sub.add_parser("list", help="the job ids under one or more roots, newest first", diff --git a/app/nullius/standard/cli.py b/app/nullius/standard/cli.py index 52a76db0d..efc3ae5ad 100644 --- a/app/nullius/standard/cli.py +++ b/app/nullius/standard/cli.py @@ -790,7 +790,7 @@ def stopped(signum, frame): def main(argv=None): - ap = argparse.ArgumentParser(prog="nullius.standard.cli", description=__doc__.split("\n\n")[0]) + ap = argparse.ArgumentParser(prog="nullius standard", description=__doc__.split("\n\n")[0]) sub = ap.add_subparsers(dest="cmd", required=True) sub.add_parser("list", help="every definition, and which pairs fit") c = sub.add_parser("check", help="check the definitions, or one file") diff --git a/app/nullius/workspace_cli.py b/app/nullius/workspace_cli.py index 54e043376..471970bfa 100644 --- a/app/nullius/workspace_cli.py +++ b/app/nullius/workspace_cli.py @@ -30,9 +30,9 @@ EPILOG = """\ examples: - PYTHONPATH=app python3 -m nullius.workspace_cli list - WORKSPACES_DIR=/srv/nullius/workspaces PYTHONPATH=app python3 -m nullius.workspace_cli list --json - PYTHONPATH=app python3 -m nullius.workspace_cli list --home /tmp/ws + nullius workspace list + WORKSPACES_DIR=/srv/nullius/workspaces nullius workspace list --json + nullius workspace list --home /tmp/ws exit codes: 0 done @@ -95,7 +95,7 @@ def _list(args) -> int: def main(argv=None) -> int: ap = argparse.ArgumentParser( - prog="python3 -m nullius.workspace_cli", description=__doc__.splitlines()[0], + prog="nullius workspace", description=__doc__.splitlines()[0], epilog=EPILOG, formatter_class=argparse.RawDescriptionHelpFormatter) sub = ap.add_subparsers(dest="command", metavar="COMMAND") ls = sub.add_parser("list", help="the workspaces under the home directory, most recently opened first", diff --git a/app/tests/test_cli.py b/app/tests/test_cli.py index 2f2338f4b..02e3ee6d4 100644 --- a/app/tests/test_cli.py +++ b/app/tests/test_cli.py @@ -105,7 +105,6 @@ def test_each_cli_has_help_with_examples_and_the_exit_codes(self): out = self.sh(module, *args, "--help") self.assertEqual(out.returncode, 0, out.stderr) self.assertIn("usage:", out.stdout) - self.assertIn(f"python3 -m nullius.{module}", out.stdout) self.assertIn("examples:", out.stdout) self.assertIn("exit codes:", out.stdout) self.assertIn("--json", out.stdout) diff --git a/app/tests/test_cli_contract.py b/app/tests/test_cli_contract.py index 06c25f587..1388f7ca0 100644 --- a/app/tests/test_cli_contract.py +++ b/app/tests/test_cli_contract.py @@ -185,7 +185,7 @@ def test_help_and_json_results_across_the_named_failure_kinds(self): with self.subTest(help=module): out = self.sh(module, "--help") self.assertEqual(out.returncode, 0, out.stderr) - for line in ("usage:", f"python3 -m nullius.{module}", "examples:", "exit codes:"): + for line in ("usage:", "examples:", "exit codes:"): self.assertIn(line, out.stdout) self.assertEqual(out.stderr, "") diff --git a/app/tests/test_unified_cli.py b/app/tests/test_unified_cli.py index 804ac9456..cd1e673b6 100644 --- a/app/tests/test_unified_cli.py +++ b/app/tests/test_unified_cli.py @@ -54,6 +54,17 @@ def test_top_level_help_and_module_entry_point(self): self.assertIn(command, result.stdout) self.assertEqual(list(self.root.iterdir()), []) + def test_each_command_help_names_the_command_as_typed(self): + for command in cli.COMMANDS: + if command == "serve": # needs Flask: the route suite reads its parser + continue + with self.subTest(command=command): + result = self.run_cli(command, "--help") + self.assertEqual(result.returncode, 0, result.stderr) + self.assertTrue(result.stdout.startswith(f"usage: nullius {command} "), result.stdout[:80]) + self.assertNotIn("PYTHONPATH", result.stdout) + self.assertNotIn("-m nullius.", result.stdout) + def test_version_uses_distribution_name_and_keeps_command_name(self): for missing, expected in ((False, "0.1.0rc1"), (True, "source checkout")): with self.subTest(missing=missing): diff --git a/app/ui_tests/test_settings_page.py b/app/ui_tests/test_settings_page.py index 72b491aa6..1c73464de 100644 --- a/app/ui_tests/test_settings_page.py +++ b/app/ui_tests/test_settings_page.py @@ -1210,6 +1210,9 @@ def args(self, argv=(), **env): os.environ.update(env) return web.parser().parse_args(list(argv)) + def test_help_names_the_command_as_typed(self): + self.assertTrue(web.parser().format_help().startswith("usage: nullius serve ")) + def test_app_host_and_app_port_are_the_defaults_and_the_flags_win(self): a = self.args(APP_HOST="0.0.0.0", APP_PORT="6000") self.assertEqual((a.host, a.port), ("0.0.0.0", 6000))