Skip to content

Commit

Permalink
Search notes (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolheiser authored Sep 30, 2022
1 parent 0e79232 commit b966575
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cmd/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
27 changes: 24 additions & 3 deletions pkgparse/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b966575

Please sign in to comment.