From 4b2c3ff37cde6765f53527f3d61d4006ae61db3f Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 12 Nov 2026 00:15:10 -0700 Subject: [PATCH 1/2] Document how main.py treats a misplaced flag and extra arguments Co-Authored-By: Claude Opus 5.5 --- README.md | 2 ++ tests/test_main.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 11a31cf..89d6e5c 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,8 @@ Passing `--exit-after-create` as the second argument renders a newly created env python main.py 100 --exit-after-create ``` +The flag is recognised only in that second position. Given first, as in `python main.py --exit-after-create`, it is read as a grid size that cannot be parsed: `Invalid grid size argument, using default of 50.` is printed and the render loop is entered as usual. Any other second argument, and every argument after the second, is ignored without a message. + Passing `--help` or `-h` in any position prints a usage line and exits with status `0`, before a window is opened, Viron is contacted, a file is written or usage reporting starts: ```bash diff --git a/tests/test_main.py b/tests/test_main.py index a44be90..920bc4b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -67,6 +67,15 @@ def test_detects_the_exit_after_create_flag(self): def test_ignores_an_unrecognized_second_argument(self): self.assertEqual(main.parseArgs(["main.py", "100", "--render-forever"]), (100, False)) + def test_the_flag_given_first_is_read_as_an_invalid_grid_size(self): + self.assertEqual(main.parseArgs(["main.py", "--exit-after-create"]), (50, False)) + + def test_the_flag_is_not_recognized_after_the_second_position(self): + self.assertEqual(main.parseArgs(["main.py", "100", "extra", "--exit-after-create"]), (100, False)) + + def test_arguments_after_the_second_are_ignored(self): + self.assertEqual(main.parseArgs(["main.py", "100", "--exit-after-create", "extra"]), (100, True)) + class TestWantsUsage(unittest.TestCase): def test_recognizes_both_spellings_of_the_flag(self): From f417a8f247c37e10164ffe0b0b4e66873f2be9fa Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 12 Nov 2026 00:16:33 -0700 Subject: [PATCH 2/2] Except --help and -h from the ignored-arguments sentence Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89d6e5c..e0190b8 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ Passing `--exit-after-create` as the second argument renders a newly created env python main.py 100 --exit-after-create ``` -The flag is recognised only in that second position. Given first, as in `python main.py --exit-after-create`, it is read as a grid size that cannot be parsed: `Invalid grid size argument, using default of 50.` is printed and the render loop is entered as usual. Any other second argument, and every argument after the second, is ignored without a message. +The flag is recognised only in that second position. Given first, as in `python main.py --exit-after-create`, it is read as a grid size that cannot be parsed: `Invalid grid size argument, using default of 50.` is printed and the render loop is entered as usual. Apart from `--help` and `-h` (below), any other second argument, and every argument after the second, is ignored without a message. Passing `--help` or `-h` in any position prints a usage line and exits with status `0`, before a window is opened, Viron is contacted, a file is written or usage reporting starts: