Skip to content

Commit

Permalink
Turn boolean values into flags based on default (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorwoods authored Aug 1, 2022
1 parent e7a3dd4 commit 9f6261c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/argsubparse/argsubparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def create_subparser(
continue
if v.default is inspect._empty:
arg_name = (k,)
if isinstance(v.annotation, bool):
if v.default is not inspect._empty:
arg_params["action"] = "store_false" if v.default else "store_true"
else:
arg_params["action"] = "store_true"
else:
arg_params["default"] = v.default
short_option = short_options.get(k)
Expand Down

0 comments on commit 9f6261c

Please sign in to comment.