-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Wrap ./pants help
based on actual terminal width
#11378
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
825ce87
Wrap `./pants help` based on actual terminal width
Eric-Arellano 120db86
Fix pantsd! Thanks Stu
Eric-Arellano 0e52a3b
Merge branch 'master' of github.com:pantsbuild/pants into column-width
Eric-Arellano 9f51439
Reduce # of syscalls while still keeping this working with pantsd
Eric-Arellano File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -163,10 +163,16 @@ def initialize_stdio(global_bootstrap_options: OptionValueContainer) -> Iterator | |||||||||||||||||
tuple(message_regex_filters), | ||||||||||||||||||
log_path, | ||||||||||||||||||
) | ||||||||||||||||||
sys.__stdin__, sys.__stdout__, sys.__stderr__ = sys.stdin, sys.stdout, sys.stderr | ||||||||||||||||||
# Install a Python logger that will route through the Rust logger. | ||||||||||||||||||
with _python_logging_setup(global_level, print_stacktrace): | ||||||||||||||||||
yield | ||||||||||||||||||
finally: | ||||||||||||||||||
sys.__stdin__, sys.__stdout__, sys.__stderr__ = ( | ||||||||||||||||||
original_stdin, | ||||||||||||||||||
original_stdout, | ||||||||||||||||||
original_stderr, | ||||||||||||||||||
) | ||||||||||||||||||
sys.stdin, sys.stdout, sys.stderr = original_stdin, original_stdout, original_stderr | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: A bit nicer symmetry with the above maybe:
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import shutil | ||
|
||
from pants.version import MAJOR_MINOR | ||
|
||
|
||
# NB: This is not memoized because that would cause Pants to not pick up terminal resizing when | ||
# using pantsd. | ||
def terminal_width(*, fallback: int = 96, padding: int = 2) -> int: | ||
return shutil.get_terminal_size(fallback=(fallback, 24)).columns - padding | ||
|
||
|
||
def docs_url(slug: str) -> str: | ||
"""Link to the Pants docs using the current version of Pants.""" | ||
return f"https://www.pantsbuild.org/v{MAJOR_MINOR}/docs/{slug}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each call to
terminal_width
is a syscall, so it might be good to just call it once at the top.