Skip to content

Commit abcf9c2

Browse files
committed
Added Search command
1 parent 426c852 commit abcf9c2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apt.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ type Package struct {
3838
// List returns a list of packages available in the system with their
3939
// respective status.
4040
func List() ([]*Package, error) {
41-
cmd := exec.Command("dpkg-query", "-W", "-f=${Package}\t${Architecture}\t${db:Status-Status}\t${Version}\n")
41+
return Search("*")
42+
}
43+
44+
// Search list packages available in the system that match the search
45+
// pattern
46+
func Search(pattern string) ([]*Package, error) {
47+
cmd := exec.Command("dpkg-query", "-W", "-f=${Package}\t${Architecture}\t${db:Status-Status}\t${Version}\n", pattern)
4248
out, err := cmd.Output()
4349
if err != nil {
4450
return nil, fmt.Errorf("running dpkg-query: %s", err)

0 commit comments

Comments
 (0)