Changed info subcommand format and added support for checking .bpm file information
This commit is contained in:
parent
e285fd792e
commit
852e615806
33
main.go
33
main.go
@ -102,15 +102,31 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
for n, pkg := range packages {
|
for n, pkg := range packages {
|
||||||
var info *utils.PackageInfo
|
var info *utils.PackageInfo
|
||||||
info = utils.GetPackageInfo(pkg, rootDir)
|
isFile := false
|
||||||
|
if stat, err := os.Stat(pkg); err == nil && !stat.IsDir() {
|
||||||
|
bpmpkg, err := utils.ReadPackage(pkg)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error: could not read package: %s\n", err)
|
||||||
|
}
|
||||||
|
info = bpmpkg.PkgInfo
|
||||||
|
isFile = true
|
||||||
|
} else {
|
||||||
|
info = utils.GetPackageInfo(pkg, rootDir)
|
||||||
|
}
|
||||||
if info == nil {
|
if info == nil {
|
||||||
log.Fatalf("Error: package (%s) is not installed\n", pkg)
|
log.Fatalf("Error: package (%s) is not installed\n", pkg)
|
||||||
}
|
}
|
||||||
fmt.Println("----------------")
|
if n != 0 {
|
||||||
fmt.Println(utils.CreateReadableInfo(true, true, true, info, rootDir))
|
fmt.Println()
|
||||||
if n == len(packages)-1 {
|
|
||||||
fmt.Println("----------------")
|
|
||||||
}
|
}
|
||||||
|
if isFile {
|
||||||
|
abs, err := filepath.Abs(pkg)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error: could not get absolute path of file (%s)\n", abs)
|
||||||
|
}
|
||||||
|
fmt.Println("File: " + abs)
|
||||||
|
}
|
||||||
|
fmt.Println(utils.CreateReadableInfo(true, true, true, info, rootDir))
|
||||||
}
|
}
|
||||||
case list:
|
case list:
|
||||||
packages, err := utils.GetInstalledPackages(rootDir)
|
packages, err := utils.GetInstalledPackages(rootDir)
|
||||||
@ -135,10 +151,10 @@ func resolveCommand() {
|
|||||||
fmt.Printf("Package (%s) could not be found\n", pkg)
|
fmt.Printf("Package (%s) could not be found\n", pkg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Println("----------------\n" + utils.CreateReadableInfo(true, true, true, info, rootDir))
|
if n != 0 {
|
||||||
if n == len(packages)-1 {
|
fmt.Println()
|
||||||
fmt.Println("----------------")
|
|
||||||
}
|
}
|
||||||
|
fmt.Println(utils.CreateReadableInfo(true, true, true, info, rootDir))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case search:
|
case search:
|
||||||
@ -146,7 +162,6 @@ func resolveCommand() {
|
|||||||
if len(searchTerms) == 0 {
|
if len(searchTerms) == 0 {
|
||||||
log.Fatalf("Error: no search terms given")
|
log.Fatalf("Error: no search terms given")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, term := range searchTerms {
|
for _, term := range searchTerms {
|
||||||
nameResults := make([]*utils.PackageInfo, 0)
|
nameResults := make([]*utils.PackageInfo, 0)
|
||||||
descResults := make([]*utils.PackageInfo, 0)
|
descResults := make([]*utils.PackageInfo, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user