mirror of
https://github.com/chubin/wttr.in
synced 2024-11-15 00:27:09 +00:00
Fix lll findings
This commit is contained in:
parent
d86f03f2b7
commit
5b80bf417b
2 changed files with 21 additions and 16 deletions
|
@ -31,7 +31,7 @@ func formatTemp(c cond) string {
|
||||||
color := func(temp int, explicitPlus bool) string {
|
color := func(temp int, explicitPlus bool) string {
|
||||||
var col int
|
var col int
|
||||||
if !config.Inverse {
|
if !config.Inverse {
|
||||||
// Extemely cold temperature must be shown with violet
|
// Extremely cold temperature must be shown with violet
|
||||||
// because dark blue is too dark
|
// because dark blue is too dark
|
||||||
col = 165
|
col = 165
|
||||||
switch temp {
|
switch temp {
|
||||||
|
@ -167,17 +167,6 @@ func formatTemp(c cond) string {
|
||||||
unitTemp[config.Imperial]),
|
unitTemp[config.Imperial]),
|
||||||
15)
|
15)
|
||||||
}
|
}
|
||||||
// if c.FeelsLikeC < t {
|
|
||||||
// if c.FeelsLikeC < 0 && t > 0 {
|
|
||||||
// explicitPlus = true
|
|
||||||
// }
|
|
||||||
// return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicitPlus), unitTemp[config.Imperial]), 15)
|
|
||||||
// } else if c.FeelsLikeC > t {
|
|
||||||
// if t < 0 && c.FeelsLikeC > 0 {
|
|
||||||
// explicitPlus = true
|
|
||||||
// }
|
|
||||||
// return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicitPlus), unitTemp[config.Imperial]), 15)
|
|
||||||
// }
|
|
||||||
return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15)
|
return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +230,9 @@ func formatWind(c cond) string {
|
||||||
cWindGustKmph := color(c.WindGustKmph)
|
cWindGustKmph := color(c.WindGustKmph)
|
||||||
cWindspeedKmph := color(c.WindspeedKmph)
|
cWindspeedKmph := color(c.WindspeedKmph)
|
||||||
if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) {
|
if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) {
|
||||||
return pad(fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), 15)
|
return pad(
|
||||||
|
fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString),
|
||||||
|
15)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pad(fmt.Sprintf("%s %s %s", windDir[c.Winddir16Point], cWindspeedKmph, unitWindString), 15)
|
return pad(fmt.Sprintf("%s %s %s", windDir[c.Winddir16Point], cWindspeedKmph, unitWindString), 15)
|
||||||
|
@ -258,7 +249,7 @@ func formatVisibility(c cond) string {
|
||||||
func formatRain(c cond) string {
|
func formatRain(c cond) string {
|
||||||
rainUnit := float32(c.PrecipMM)
|
rainUnit := float32(c.PrecipMM)
|
||||||
if config.Imperial {
|
if config.Imperial {
|
||||||
rainUnit = float32(c.PrecipMM) * 0.039
|
rainUnit = c.PrecipMM * 0.039
|
||||||
}
|
}
|
||||||
if c.ChanceOfRain != "" {
|
if c.ChanceOfRain != "" {
|
||||||
return pad(fmt.Sprintf(
|
return pad(fmt.Sprintf(
|
||||||
|
@ -336,9 +327,21 @@ func formatCond(cur []string, c cond, current bool) (ret []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if config.RightToLeft {
|
if config.RightToLeft {
|
||||||
ret = append(ret, fmt.Sprintf("%v %v %v", cur[0], desc, icon[0]), fmt.Sprintf("%v %v %v", cur[1], formatTemp(c), icon[1]), fmt.Sprintf("%v %v %v", cur[2], formatWind(c), icon[2]), fmt.Sprintf("%v %v %v", cur[3], formatVisibility(c), icon[3]), fmt.Sprintf("%v %v %v", cur[4], formatRain(c), icon[4]))
|
ret = append(
|
||||||
|
ret,
|
||||||
|
fmt.Sprintf("%v %v %v", cur[0], desc, icon[0]),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[1], formatTemp(c), icon[1]),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[2], formatWind(c), icon[2]),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[3], formatVisibility(c), icon[3]),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[4], formatRain(c), icon[4]))
|
||||||
} else {
|
} else {
|
||||||
ret = append(ret, fmt.Sprintf("%v %v %v", cur[0], icon[0], desc), fmt.Sprintf("%v %v %v", cur[1], icon[1], formatTemp(c)), fmt.Sprintf("%v %v %v", cur[2], icon[2], formatWind(c)), fmt.Sprintf("%v %v %v", cur[3], icon[3], formatVisibility(c)), fmt.Sprintf("%v %v %v", cur[4], icon[4], formatRain(c)))
|
ret = append(
|
||||||
|
ret,
|
||||||
|
fmt.Sprintf("%v %v %v", cur[0], icon[0], desc),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[1], icon[1], formatTemp(c)),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[2], icon[2], formatWind(c)),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[3], icon[3], formatVisibility(c)),
|
||||||
|
fmt.Sprintf("%v %v %v", cur[4], icon[4], formatRain(c)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -115,6 +115,7 @@ func printDay(w weather) (ret []string) {
|
||||||
"└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│"
|
"└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
ret = append([]string{
|
ret = append([]string{
|
||||||
" ┌─────────────┐ ",
|
" ┌─────────────┐ ",
|
||||||
"┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐",
|
"┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐",
|
||||||
|
@ -123,6 +124,7 @@ func printDay(w weather) (ret []string) {
|
||||||
},
|
},
|
||||||
ret...)
|
ret...)
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
return append(ret,
|
return append(ret,
|
||||||
"└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘")
|
"└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue