Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading