From cd7640971dec542505915fbbac0d7a49fda079a2 Mon Sep 17 00:00:00 2001 From: beroda <117822458+beroda@users.noreply.github.com> Date: Thu, 30 Oct 2025 17:22:17 +0100 Subject: [PATCH 1/2] Add failing test --- tests/data/test_cli.py | 16 ++++++++++++++++ tests/test_server.py | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/data/test_cli.py diff --git a/tests/data/test_cli.py b/tests/data/test_cli.py new file mode 100644 index 0000000..cb71fd6 --- /dev/null +++ b/tests/data/test_cli.py @@ -0,0 +1,16 @@ +from argparse import ArgumentParser + +from trame.app import get_server + + +def main(): + parser = ArgumentParser() + parser.add_argument("--f", dest="foo") + parser.parse_known_args() + + server = get_server("test_cli") + server.start(timeout=1, open_browser=False) + + +if __name__ == "__main__": + main() diff --git a/tests/test_server.py b/tests/test_server.py index 18f13a1..24b583b 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -1,5 +1,7 @@ import asyncio import os +import subprocess +import sys from pathlib import Path import pytest @@ -125,6 +127,11 @@ def another_method(): server.client_type = "vue3" +def test_cli_args_collision(pytestconfig: pytest.Config): + cli = pytestconfig.rootpath / "tests/data/test_cli.py" + subprocess.run([sys.executable, str(cli), "--f", "foo"], check=True) + + def test_cli(): server = get_server("test_cli") child_server = server.create_child_server(prefix="child_") From a7a4fbef3c165039fac2dfdc4813eed6dbe87ea0 Mon Sep 17 00:00:00 2001 From: beroda <117822458+beroda@users.noreply.github.com> Date: Thu, 30 Oct 2025 17:22:45 +0100 Subject: [PATCH 2/2] Fix CLI abbreviation --- trame_server/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trame_server/core.py b/trame_server/core.py index 5b043dc..74e9113 100644 --- a/trame_server/core.py +++ b/trame_server/core.py @@ -348,7 +348,10 @@ def cli(self): if self._cli_parser: return self._cli_parser - self._cli_parser = ArgumentParser(description="Kitware trame") + self._cli_parser = ArgumentParser( + description="Kitware trame", + allow_abbrev=False, + ) # Trame specific args self._cli_parser.add_argument(