From 625de52992dae42bb730ba999d0c7b7493b93f22 Mon Sep 17 00:00:00 2001 From: Alex Borodin Date: Fri, 1 Dec 2023 12:16:37 +0100 Subject: [PATCH] fixup: always output full TM name in list; use safe parsing option for TMIDs for comparison --- internal/app/cli/list.go | 6 +++--- internal/model/search.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/app/cli/list.go b/internal/app/cli/list.go index baa34fc0..8df7f8ea 100644 --- a/internal/app/cli/list.go +++ b/internal/app/cli/list.go @@ -28,12 +28,12 @@ func printToC(toc model.SearchResult, filter string) { colWidth := columnWidth() table := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) - _, _ = fmt.Fprintf(table, "NAME\tMANUFACTURER\tMODEL\n") + _, _ = fmt.Fprintf(table, "MANUFACTURER\tMODEL\tNAME\n") for _, value := range toc.Entries { - name := elideString(value.Name, colWidth) + name := value.Name man := elideString(value.Manufacturer.Name, colWidth) mdl := elideString(value.Mpn, colWidth) - _, _ = fmt.Fprintf(table, "%s\t%s\t%s\n", name, man, mdl) + _, _ = fmt.Fprintf(table, "%s\t%s\t%s\n", man, mdl, name) } _ = table.Flush() } diff --git a/internal/model/search.go b/internal/model/search.go index 68b4eb69..ef388262 100644 --- a/internal/model/search.go +++ b/internal/model/search.go @@ -42,18 +42,18 @@ func NewFoundEntryFromTOCEntry(e *TOCEntry, foundIn string) FoundEntry { func mergeFoundVersions(vs1, vs2 []FoundVersion) []FoundVersion { vs1 = append(vs1, vs2...) - // whether the TMIDs are official or not is not important for these comparisons + // whether the TMIDs are actually official or not is not important for these comparisons slices.SortStableFunc(vs1, func(a, b FoundVersion) int { - tmid1, _ := ParseTMID(a.TMID, false) - tmid2, _ := ParseTMID(b.TMID, false) + tmid1, _ := ParseTMID(a.TMID, true) + tmid2, _ := ParseTMID(b.TMID, true) if tmid1.Equals(tmid2) { return -strings.Compare(tmid1.Version.Timestamp, tmid2.Version.Timestamp) // sort in reverse chronological order within the same TMID } return strings.Compare(a.TMID, b.TMID) }) return slices.CompactFunc(vs1, func(v1, v2 FoundVersion) bool { - tmid1, _ := ParseTMID(v1.TMID, false) - tmid2, _ := ParseTMID(v2.TMID, false) + tmid1, _ := ParseTMID(v1.TMID, true) + tmid2, _ := ParseTMID(v2.TMID, true) return tmid1.Equals(tmid2) }) }