Skip to content

Commit

Permalink
Hide default values for boolean flags
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 14, 2021
1 parent 3c438da commit 5c6b610
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions dcargs/_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ def _bool_flags(arg: ArgumentDefinition) -> _ArgumentTransformOutput:
if arg.type != bool:
return arg, None

# Populate helptext for boolean flags => don't show default value, which can be
# confusing.
helptext = (_docstrings.get_field_docstring(arg.parent_class, arg.field.name),)
arg = dataclasses.replace(
arg,
help=helptext if helptext is not None else "",
)

if arg.default is None:
return (
dataclasses.replace(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="dcargs",
version="0.0.6",
version="0.0.7",
description="Portable, reusable, strongly typed CLIs from dataclass definitions",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 5c6b610

Please sign in to comment.