-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Allow output from commands to be wrapped to terminal width (fix #81) #201
Conversation
Codecov Report
@@ Coverage Diff @@
## master #201 +/- ##
==========================================
+ Coverage 95.33% 95.42% +0.09%
==========================================
Files 24 24
Lines 1244 1269 +25
Branches 279 287 +8
==========================================
+ Hits 1186 1211 +25
Misses 33 33
Partials 25 25
|
Please can you comment with some screenshots of what this looks like to confirm I'm seeing the same thing |
Thanks for taking a look at this! First, I'll show some good cases for most commands, then I'll use Rank:Diff:Index:List-metrics:Report wide, default metrics:Report very wide, default metrics:Here we see that this PR isn't optimal about using available width: it doesn't actually need wrapping here. Report very wide, many metrics:How it sorta breaks:When the terminal is narrow enough, table cells become vertical text one character wide. That might still be better than the otherwise overlapping output in some situation, but it does look silly. How it breaks:When the terminal is narrow enough, the code tries to output the vertical text as above, but fails and the result is harder to read than the previous overlapping output we'd get. There's some more context at #81 (comment) |
src/wily/__main__.py
Outdated
@click.option( | ||
"-w", | ||
"--wrap/--no-wrap", | ||
default=False, |
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.
Please change to default=True
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.
Thanks for reviewing! Changed here and in all other commands, was that the intention?
Great, in that case please change the PR so this new behaviour is on by default. This looks much better |
Tests aren't passing due to an issue I see no relation with this PR, but could be wrong. It's fixed by #203, and I could make the fix in this PR instead if that's cleaner. |
Adds
--wrap
to commands, so output that is too wide for a given terminal width is wrapped inside the table cells.Uses
shutil.get_terminal_size()
to get terminal size, then calculates an approximation of maximum column width and passes that asmaxcolwidths
andmaxheadercolwidths
parameters to tabulate.tabulate().Adds some tests, but not exact output testing.
Fixes #81, except for very narrow terminals with lots of metrics.