Adds pm ls
This commit is contained in:
@@ -2,6 +2,8 @@ package db
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -33,6 +35,19 @@ func IsInstalled(root string, m pm.Meta) (bool, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// ListInstalled pretty prints the installed database to w.
|
||||
func ListInstalled(root string, w io.Writer) error {
|
||||
db, err := loadi(root)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "loading installed db")
|
||||
}
|
||||
|
||||
for m := range db.Traverse() {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n", m.Name, m.Version, m.Remote.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadi(root string) (pm.Installed, error) {
|
||||
r := pm.Installed{}
|
||||
dbn := filepath.Join(root, in)
|
||||
|
||||
Reference in New Issue
Block a user