From 8654792c7269a9b4aa9071c6ea887347a1eba5ae Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 24 Feb 2023 13:36:29 -0800 Subject: [PATCH] :sparkles: - Add "Narrow Full" format https://github.com/chubin/wttr.in/issues/151#issuecomment-1127220910 --- lib/parse_query.py | 2 ++ lib/view/wttr.py | 3 +++ share/we-lang/main.go | 2 ++ share/we-lang/view1.go | 18 +++++++++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/parse_query.py b/lib/parse_query.py index e598a2b..f0787b6 100644 --- a/lib/parse_query.py +++ b/lib/parse_query.py @@ -81,6 +81,8 @@ def parse_query(args): result['force-ansi'] = True if 'n' in q: result['narrow'] = True + if 'N' in q: + result['narrow-full'] = True if 'm' in q: result['use_metric'] = True if 'M' in q: diff --git a/lib/view/wttr.py b/lib/view/wttr.py index 72222d3..85408d8 100644 --- a/lib/view/wttr.py +++ b/lib/view/wttr.py @@ -84,6 +84,9 @@ def _wego_wrapper(location, parsed_query): if parsed_query.get('narrow'): cmd += ['-narrow'] + if parsed_query.get('narrow-full'): + cmd += ['-narrow-full'] + if lang and lang in SUPPORTED_LANGS: cmd += ['-lang=%s'%lang] diff --git a/share/we-lang/main.go b/share/we-lang/main.go index b1a1f50..a6af1d0 100644 --- a/share/we-lang/main.go +++ b/share/we-lang/main.go @@ -29,6 +29,7 @@ type configuration struct { Inverse bool Lang string Narrow bool + NarrowFull bool LocationName string WindMS bool RightToLeft bool @@ -71,6 +72,7 @@ func init() { flag.BoolVar(&config.Imperial, "imperial", false, "Use imperial units") flag.BoolVar(&config.Inverse, "inverse", false, "Use inverted colors") flag.BoolVar(&config.Narrow, "narrow", false, "Narrow output (two columns)") + flag.BoolVar(&config.NarrowFull, "narrow-full", false, "Narrow output w/ all dayparts (two columns, two rows)") flag.StringVar(&config.LocationName, "location_name", "", "Location name (used in the caption)") flag.BoolVar(&config.WindMS, "wind_in_ms", false, "Show wind speed in m/s") flag.BoolVar(&config.RightToLeft, "right_to_left", false, "Right to left script") diff --git a/share/we-lang/view1.go b/share/we-lang/view1.go index 357fea5..1cff76a 100644 --- a/share/we-lang/view1.go +++ b/share/we-lang/view1.go @@ -88,7 +88,23 @@ func printDay(w weather) (ret []string) { if t, ok := daytimeTranslation[config.Lang]; ok { trans = t } - if config.Narrow { + if config.NarrowFull { + names_1 := "│ " + justifyCenter(trans[0], 16) + + "└──────┬──────┘" + justifyCenter(trans[1], 16) + " │" + names_2 := "│ " + justifyCenter(trans[2], 16) + + "└──────┬──────┘" + justifyCenter(trans[3], 16) + " │" + + ret = append([]string{ + " ┌─────────────┐ ", + "┌───────────────────────" + dateFmt + "───────────────────────┐", + names_1, + names_2, + "├──────────────────────────────┼──────────────────────────────┤"}, + ret...) + + return append(ret, + "└──────────────────────────────┴──────────────────────────────┘") + } else if config.Narrow { names := "│ " + justifyCenter(trans[1], 16) + "└──────┬──────┘" + justifyCenter(trans[3], 16) + " │"