Skip to content

Commit

Permalink
Consider indentation for help positions
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Oct 5, 2022
1 parent d5e6f80 commit a04dfdd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dcargs/_argparse_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,13 @@ def _dcargs_format_root(self):

def _format_action(self, action: argparse.Action):
invocation = self.formatter._format_action_invocation(action)
indent = self.formatter._current_indent
help_position = min(
self.formatter._action_max_length + 4, self.formatter._max_help_position
self.formatter._action_max_length + 4 + indent,
self.formatter._max_help_position,
)
if self.formatter._fixed_help_position:
help_position = 4
indent = self.formatter._current_indent

item_parts: List[RenderableType] = []

Expand Down
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 = "dcargs"
version = "0.3.19"
version = "0.3.20"
description = "Strongly typed, zero-effort CLI interfaces"
authors = ["brentyi <[email protected]>"]
include = ["./dcargs/**/*"]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ def main2(x: Callable = nn.ReLU):

helptext = _get_helptext(main2)
assert "--x {fixed}" in helptext
assert "(fixed to: <class 'torch.nn" in helptext
assert "(fixed to:" in helptext
assert "torch" in helptext


def test_suppressed():
Expand Down

0 comments on commit a04dfdd

Please sign in to comment.