Compare commits

...

2 Commits

Author SHA1 Message Date
a106100312 Show version of installed package when listing installed packages
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-12-01 00:14:07 -08:00
df72d95ab7 Disable root in ls command 2022-12-01 00:11:27 -08:00

10
list.go
View File

@ -49,7 +49,7 @@ func listCmd(c *cli.Context) error {
log.Fatal("Unable to detect supported package manager on system").Send()
}
installed, err = mgr.ListInstalled(nil)
installed, err = mgr.ListInstalled(&manager.Opts{AsRoot: false})
if err != nil {
log.Fatal("Error listing installed packages").Err(err).Send()
}
@ -62,13 +62,17 @@ func listCmd(c *cli.Context) error {
return err
}
version := pkg.Version
if c.Bool("installed") {
if _, ok := installed[pkg.Name]; !ok {
instVersion, ok := installed[pkg.Name]
if !ok {
return nil
} else {
version = instVersion
}
}
fmt.Printf("%s/%s %s\n", pkg.Repository, pkg.Name, pkg.Version)
fmt.Printf("%s/%s %s\n", pkg.Repository, pkg.Name, version)
return nil
})
if err != nil {