Open YarnSphere opened 7 years ago
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!
tput cols
COLUMNS
With different WIDTHs we would have:
WIDTH
WIDTH >= 125:
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:
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):
WIDTH < 63
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?
JFYI: At the moment you can use the new n (narrow) option for the 2-column output.
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:
This would make it possible to use
tput cols
or theCOLUMNS
environment variable to always have pretty printed tables!With different
WIDTH
s we would have:WIDTH >= 125
:63 <= WIDTH < 125
:WIDTH < 63
(only looks good ifWIDTH >= 32
):Note: I aligned the date in this last example to the left, but maybe try something else! :-D
What are your thoughts on this?