Skip to content

Commit

Permalink
Release 0.6.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuba314 committed Mar 17, 2024
1 parent c686b0c commit 4d2fa15
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "arcparse"
version = "0.6.11"
version = "0.6.12"
description = "Declare program arguments declaratively and type-safely"
license = "MIT"
authors = ["Jakub Rozek <[email protected]>"]
Expand Down
27 changes: 27 additions & 0 deletions tests/test_subparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,30 @@ class Args:

with pytest.raises(InvalidParser):
arcparser(Args)


def test_nested_subparsers() -> None:
class Bar:
bar: bool

class Baz:
baz: bool

class BarBaz:
bar_or_baz: Bar | Baz = subparsers("bar", "baz")

class Boo:
boo: bool

@arcparser
class Args:
barbaz_or_boo: BarBaz | Boo = subparsers("barbaz", "boo")

parsed = Args.parse("barbaz bar --bar".split())
assert isinstance(barbaz := parsed.barbaz_or_boo, BarBaz) and isinstance(bar := barbaz.bar_or_baz, Bar) and bar.bar

parsed = Args.parse("barbaz baz --baz".split())
assert isinstance(barbaz := parsed.barbaz_or_boo, BarBaz) and isinstance(baz := barbaz.bar_or_baz, Baz) and baz.baz

parsed = Args.parse("boo --boo".split())
assert isinstance(boo := parsed.barbaz_or_boo, Boo) and boo.boo

0 comments on commit 4d2fa15

Please sign in to comment.