diff --git a/cmd/search/search.go b/cmd/search/search.go index 17c9be6..931a588 100644 --- a/cmd/search/search.go +++ b/cmd/search/search.go @@ -91,13 +91,22 @@ The "search" subcommand starts an interactive window to find and display info ab if i == -1 { return "" } - return wrapText(fmt.Sprintf("%s: %s\n\n%s:\n %s\n\n%s:\n%s", + preview := fmt.Sprintf("%s: %s\n\n%s:\n %s\n\n%s:\n%s", "📦 Title", pkgInfos[i].Title, "💾 Tagline", pkgInfos[i].Tagline, "📄 About", - pkgInfos[i].About), w) + pkgInfos[i].About, + ) + notes := pkgInfos[i].InstallNotes() + if notes != "" { + preview += fmt.Sprintf("\n\n%s:\n %s", + "📝 Notes", + pkgInfos[i].InstallNotes(), + ) + } + return wrapText(preview, w) })) if err != nil { color.HiBlack("No package selected.") diff --git a/pkgparse/info.go b/pkgparse/info.go index 2bad953..889da35 100644 --- a/pkgparse/info.go +++ b/pkgparse/info.go @@ -13,9 +13,30 @@ import ( ) type PkgInfo struct { - Title string - Tagline string - About string + Title string `yaml:"-"` + Tagline string `yaml:"tagline"` + About string `yaml:"about"` + InstallNote string `yaml:"install_note"` + RemoveNote string `yaml:"remove_note"` + OsInfo map[string]struct { + InstallNote string `yaml:"install_note"` + RemoveNote string `yaml:"remove_note"` + } `yaml:"os_map"` +} + +func (pkgInfo *PkgInfo) InstallNotes() string { + var installNotes string + + pkgOS := GOOStoPkgOs[utils.GOOS] + note := pkgInfo.InstallNote + osNote := pkgInfo.OsInfo[pkgOS].InstallNote + if note != "" { + installNotes += note + "\n" + } + if osNote != "" { + installNotes += osNote + "\n" + } + return installNotes } func ParsePkgInfo(pkgRepo, pkg string) (*PkgInfo, error) {