Skip to content

Commit 9f6261c

Browse files
authored
Turn boolean values into flags based on default (#4)
1 parent e7a3dd4 commit 9f6261c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/argsubparse/argsubparse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def create_subparser(
7070
continue
7171
if v.default is inspect._empty:
7272
arg_name = (k,)
73+
if isinstance(v.annotation, bool):
74+
if v.default is not inspect._empty:
75+
arg_params["action"] = "store_false" if v.default else "store_true"
76+
else:
77+
arg_params["action"] = "store_true"
7378
else:
7479
arg_params["default"] = v.default
7580
short_option = short_options.get(k)

0 commit comments

Comments
 (0)