diff --git a/README.md b/README.md index 11a31cf..e0190b8 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. 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: ```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):