Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display multiline help nicely. #10366

Merged
merged 1 commit into from Jul 15, 2020
Merged

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Jul 15, 2020

This includes:

  • Respecting any embedded newlines in the option help string.
  • Formatting option values (defaults, current value) nicely
    when they are large lists and dicts.

[ci skip-rust-tests]

This includes:

- Respecting any embedded newlines in the option help string.
- Formatting option values (defaults, current value) nicely
  when they are large lists and dicts.

[ci skip-rust-tests]
@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Jul 15, 2020

Screenshot 2020-07-15 10 30 02

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Jul 15, 2020

Note: uses executable tool help as the motivating use-case. So, among other things, expands the wrapping boundary from 80 to 96 to accommodate that case well.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! You'll want to update a few other places, too:

▶ rg -C1 '\b80\b' -g '*.py'
src/python/pants/help/help_printer.py
83-                name = cyan(name)
84:            description_lines = textwrap.wrap(descr, 80 - chars_before_description)
85-            if len(description_lines) > 1:

src/python/pants/help/help_formatter.py
78-            f"{indent}{'  ' if i != 0 else ''}{self._maybe_cyan(s)}"
79:            for i, s in enumerate(wrap(f"{choices}", 80))
80-        ]
--
98-        ]
99:        description_lines = [f"{indent}{s}" for s in wrap(ohi.help, 80)]
100-        lines = [

src/python/pants/option/parser.py
424-                ),
425:                80,
426-            )
--
434-            ),
435:            80,
436-        )

src/python/pants/backend/pants_info/list_target_types.py
67-        else:
68:            description_lines = textwrap.wrap(self.description, 80 - chars_before_description)
69-            if len(description_lines) > 1:
--
160-        if self.description:
161:            lines.extend(f"{indent}{line}" for line in textwrap.wrap(self.description, 80))
162-        return "\n".join(f"{indent}{line}" for line in lines)
--
234-                    "information for a particular target type.",
235:                    80,
236-                ),

src/python/pants/core/goals/test.py
314-            console.print_stderr(
315:                f"{result.address.reference():80}.....{result.test_result.status.value:>10}"
316-            )

It'd probably be good to de-magic-number this. I only didn't do that at first because I don't know where to put it without causing dep cycles.

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Jul 15, 2020

Not sure we need to change how other things wrap - those can stay at 80 I think.

@benjyw benjyw merged commit dfddfd6 into pantsbuild:master Jul 15, 2020
@benjyw benjyw deleted the multiline_help branch July 15, 2020 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants