Skip to content

Commit

Permalink
docs: add additional field 'fromfile' for options in the help-all goa…
Browse files Browse the repository at this point in the history
…l output (#17944)

* docs: add additional field 'fromfile' for options in the help-all goal output

* Reword

* Fix tests

* Improve wording
  • Loading branch information
AlexTereshenkov authored Jan 8, 2023
1 parent 59c6b53 commit aad7b8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/python/pants/help/help_formatter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def _format_for_single_option(**kwargs):
choices=None,
comma_separated_choices=None,
value_history=OptionValueHistory((RankedValue(Rank.HARDCODED, None),)),
fromfile=False,
)
ohi = replace(ohi, **kwargs)
lines = HelpFormatter(
Expand Down
4 changes: 4 additions & 0 deletions src/python/pants/help/help_info_extracter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class OptionHelpInfo:
removal_version: If deprecated: The version at which this option is to be removed.
removal_hint: If deprecated: The removal hint message registered for this option.
choices: If this option has a constrained set of choices, a tuple of the stringified choices.
fromfile: Supports reading the option value from a file when using `@filepath`.
"""

display_args: tuple[str, ...]
Expand All @@ -115,6 +116,7 @@ class OptionHelpInfo:
choices: tuple[str, ...] | None
comma_separated_choices: str | None
value_history: OptionValueHistory | None
fromfile: bool


@dataclass(frozen=True)
Expand Down Expand Up @@ -973,6 +975,7 @@ def get_option_help_info(self, args, kwargs):

target_field_name = f"{self._scope_prefix}_{option_field_name_for(args)}".replace("-", "_")
environment_aware = kwargs.get("environment_aware") is True
fromfile = kwargs.get("fromfile", False)

ret = OptionHelpInfo(
display_args=tuple(display_args),
Expand All @@ -992,5 +995,6 @@ def get_option_help_info(self, args, kwargs):
choices=choices,
comma_separated_choices=None if choices is None else ", ".join(choices),
value_history=None,
fromfile=fromfile,
)
return ret
5 changes: 5 additions & 0 deletions src/python/pants/help/help_info_extracter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": int,
"default": 42,
"fromfile": False,
"help": "Option 1",
"deprecation_active": False,
"deprecated_message": None,
Expand All @@ -347,6 +348,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": LogLevel,
"default": LogLevel.INFO,
"fromfile": False,
"help": "Set the logging level.",
"deprecation_active": False,
"deprecated_message": None,
Expand All @@ -366,6 +368,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
"deprecation_active": False,
"display_args": ("--backend-packages=\"['<str>', '<str>', ...]\"",),
"env_var": "PANTS_BACKEND_PACKAGES",
"fromfile": False,
"help": "",
"removal_hint": None,
"removal_version": None,
Expand Down Expand Up @@ -395,6 +398,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
"deprecation_active": False,
"display_args": ("--pythonpath=\"['<str>', '<str>', ...]\"",),
"env_var": "PANTS_PYTHONPATH",
"fromfile": False,
"help": "",
"removal_hint": None,
"removal_version": None,
Expand Down Expand Up @@ -440,6 +444,7 @@ def fake_consumed_scopes_mapper(scope: str) -> Tuple[str, ...]:
},
"typ": bool,
"default": True,
"fromfile": False,
"help": "Option 2",
"deprecation_active": False,
"deprecated_message": None,
Expand Down

0 comments on commit aad7b8b

Please sign in to comment.