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

Support different terminal widths #65

Open
YarnSphere opened this issue Jan 25, 2017 · 1 comment
Open

Support different terminal widths #65

YarnSphere opened this issue Jan 25, 2017 · 1 comment

Comments

@YarnSphere
Copy link

I wonder if you could add an option to specify the width of your terminal so that the tables are always pretty printed. Something like:

$ curl "wttr.in/?w=WIDTH"

This would make it possible to use tput cols or the COLUMNS environment variable to always have pretty printed tables!

With different WIDTHs we would have:

WIDTH >= 125:

                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ Wed 25. Jan ├───────────────────────┬──────────────────────────────┐
│           Morning            │             Noon      └──────┬──────┘    Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │     \   /     Sunny          │               Cloudy         │      .-.      Light drizzle  │
│      .-.      10 – 11 °C     │      .-.      15 °C          │      .--.     11 – 12 °C     │     (   ).    10 – 12 °C     │
│   ― (   ) ―   ↖ 7 – 9 km/h   │   ― (   ) ―   ↑ 13 – 14 km/h │   .-(    ).   ↑ 14 – 22 km/h │    (___(__)   ↑ 15 – 24 km/h │
│      `-’      10 km          │      `-’      10 km          │  (___.__)__)  10 km          │     ‘ ‘ ‘ ‘   2 km           │
│     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘

63 <= WIDTH < 125:

                        ┌─────────────┐
┌───────────────────────┤ Wed 25. Jan ├───────────────────────┐
│           Morning     └──────┬──────┘      Noon             │
├──────────────────────────────┼──────────────────────────────┤
│     \   /     Sunny          │     \   /     Sunny          │
│      .-.      10 – 11 °C     │      .-.      15 °C          │
│   ― (   ) ―   ↖ 7 – 9 km/h   │   ― (   ) ―   ↑ 13 – 14 km/h │
│      `-’      10 km          │      `-’      10 km          │
│     /   \     0.0 mm | 0%    │     /   \     0.0 mm | 0%    │
├──────────────────────────────┼──────────────────────────────┤
│           Evening            │            Night             │
├──────────────────────────────┼──────────────────────────────┤
│               Cloudy         │      .-.      Light drizzle  │
│      .--.     11 – 12 °C     │     (   ).    10 – 12 °C     │
│   .-(    ).   ↑ 14 – 22 km/h │    (___(__)   ↑ 15 – 24 km/h │
│  (___.__)__)  10 km          │     ‘ ‘ ‘ ‘   2 km           │
│               0.0 mm | 0%    │    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┴──────────────────────────────┘

WIDTH < 63 (only looks good if WIDTH >= 32):

┌─────────────┐
│ Wed 25. Jan │
├─────────────┴────────────────┐
│           Morning            │
├──────────────────────────────┤
│     \   /     Sunny          │
│      .-.      10 – 11 °C     │
│   ― (   ) ―   ↖ 7 – 9 km/h   │
│      `-’      10 km          │
│     /   \     0.0 mm | 0%    │
├──────────────────────────────┤
│             Noon             │
├──────────────────────────────┤
│     \   /     Sunny          │
│      .-.      15 °C          │
│   ― (   ) ―   ↑ 13 – 14 km/h │
│      `-’      10 km          │
│     /   \     0.0 mm | 0%    │
├──────────────────────────────┤
│           Evening            │
├──────────────────────────────┤
│               Cloudy         │
│      .--.     11 – 12 °C     │
│   .-(    ).   ↑ 14 – 22 km/h │
│  (___.__)__)  10 km          │
│               0.0 mm | 0%    │
├──────────────────────────────┤
│            Night             │
├──────────────────────────────┤
│      .-.      Light drizzle  │
│     (   ).    10 – 12 °C     │
│    (___(__)   ↑ 15 – 24 km/h │
│     ‘ ‘ ‘ ‘   2 km           │
│    ‘ ‘ ‘ ‘    0.5 mm | 95%   │
└──────────────────────────────┘

Note: I aligned the date in this last example to the left, but maybe try something else! :-D

What are your thoughts on this?

@chubin
Copy link
Owner

chubin commented Mar 15, 2017

JFYI: At the moment you can use the new n (narrow) option for the 2-column output.

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

No branches or pull requests

2 participants