- Add "Narrow Full" format

https://github.com/chubin/wttr.in/issues/151#issuecomment-1127220910
This commit is contained in:
David Young 2023-02-24 13:36:29 -08:00
parent 60e1a3bf68
commit 8654792c72
4 changed files with 24 additions and 1 deletions

View file

@ -81,6 +81,8 @@ def parse_query(args):
result['force-ansi'] = True result['force-ansi'] = True
if 'n' in q: if 'n' in q:
result['narrow'] = True result['narrow'] = True
if 'N' in q:
result['narrow-full'] = True
if 'm' in q: if 'm' in q:
result['use_metric'] = True result['use_metric'] = True
if 'M' in q: if 'M' in q:

View file

@ -84,6 +84,9 @@ def _wego_wrapper(location, parsed_query):
if parsed_query.get('narrow'): if parsed_query.get('narrow'):
cmd += ['-narrow'] cmd += ['-narrow']
if parsed_query.get('narrow-full'):
cmd += ['-narrow-full']
if lang and lang in SUPPORTED_LANGS: if lang and lang in SUPPORTED_LANGS:
cmd += ['-lang=%s'%lang] cmd += ['-lang=%s'%lang]

View file

@ -29,6 +29,7 @@ type configuration struct {
Inverse bool Inverse bool
Lang string Lang string
Narrow bool Narrow bool
NarrowFull bool
LocationName string LocationName string
WindMS bool WindMS bool
RightToLeft bool RightToLeft bool
@ -71,6 +72,7 @@ func init() {
flag.BoolVar(&config.Imperial, "imperial", false, "Use imperial units") flag.BoolVar(&config.Imperial, "imperial", false, "Use imperial units")
flag.BoolVar(&config.Inverse, "inverse", false, "Use inverted colors") flag.BoolVar(&config.Inverse, "inverse", false, "Use inverted colors")
flag.BoolVar(&config.Narrow, "narrow", false, "Narrow output (two columns)") 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.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.WindMS, "wind_in_ms", false, "Show wind speed in m/s")
flag.BoolVar(&config.RightToLeft, "right_to_left", false, "Right to left script") flag.BoolVar(&config.RightToLeft, "right_to_left", false, "Right to left script")

View file

@ -88,7 +88,23 @@ func printDay(w weather) (ret []string) {
if t, ok := daytimeTranslation[config.Lang]; ok { if t, ok := daytimeTranslation[config.Lang]; ok {
trans = t 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) + names := "│ " + justifyCenter(trans[1], 16) +
"└──────┬──────┘" + justifyCenter(trans[3], 16) + " │" "└──────┬──────┘" + justifyCenter(trans[3], 16) + " │"