clean up supernums

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main
jolheiser 2022-10-09 18:02:45 -05:00
parent dcd4f08b0c
commit 3797df7022
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 22 additions and 5 deletions

27
main.go
View File

@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"time"
@ -26,8 +27,19 @@ var (
"i": "ⓘ",
"w": "⚠",
}
supernums = "⁰¹²³⁴⁵⁶⁷⁸⁹"
refresh = time.Hour * 24 * 30
supernums = map[int]string{
0: "⁰",
1: "¹",
2: "²",
3: "³",
4: "⁴",
5: "⁵",
6: "⁶",
7: "⁷",
8: "⁸",
9: "⁹",
}
refresh = time.Hour * 24 * 30
)
func main() {
@ -143,12 +155,17 @@ func formatFeat(feat data, d Data, short bool) string {
}
if !short {
for num, note := range feat.NotesByNum {
nums := make([]string, 0, len(feat.NotesByNum))
for num := range feat.NotesByNum {
nums = append(nums, num)
}
sort.Strings(nums)
for _, num := range nums {
n, _ := strconv.Atoi(num)
if _, ok := needNote[n]; !ok {
continue
}
out.WriteString(fmt.Sprintf("\t\t%s%s\n", color.YellowString(string(supernums[n])), note))
out.WriteString(fmt.Sprintf("\t\t%s%s\n", color.YellowString(supernums[n]), feat.NotesByNum[num]))
}
if feat.Notes != "" {
out.WriteString(fmt.Sprintf("\t %s %s", resultmap["i"], replaceNoteRe.ReplaceAllString(feat.Notes, " ")))
@ -180,7 +197,7 @@ func makeResult(stat browserStat, nums map[int]struct{}) string {
if match != nil {
num, _ := strconv.Atoi(match[1])
nums[num] = struct{}{}
out.WriteString(string(supernums[num]))
out.WriteString(supernums[num])
}
if stat.usage > 0 {
str := out.String()