Updates SearchCommand
This commit is contained in:
parent
90868e6168
commit
d47e63d620
1 changed files with 4 additions and 28 deletions
|
|
@ -1,13 +1,10 @@
|
|||
package Commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/grpc"
|
||||
"lpm-cli/Lotus"
|
||||
proto "lpm-cli/Proto/lpm/go"
|
||||
"time"
|
||||
"lpm-cli/ProtoHandler"
|
||||
)
|
||||
|
||||
func NewSearchCommand() *cli.Command {
|
||||
|
|
@ -21,31 +18,10 @@ func NewSearchCommand() *cli.Command {
|
|||
HelpName: "search",
|
||||
Action: func(c *cli.Context) error {
|
||||
|
||||
//TODO Remove Hardcoded addr
|
||||
conn, err := grpc.Dial("faf-notebook2:9090", grpc.WithInsecure())
|
||||
if err != nil{
|
||||
logger.Fatal(err)
|
||||
}
|
||||
packages := ProtoHandler.SearchPackages("a platform", []string{"amd64", "i386"}, "chrome")
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
lrc := proto.NewLpmRegistryClient(conn)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
|
||||
r, connErr := lrc.Search(ctx, &proto.SearchRequest {Platform: "noot", Architecture: nil, Query: "Schnitzel"})
|
||||
if connErr != nil {
|
||||
logger.Fatal(connErr)
|
||||
}
|
||||
|
||||
packages := r.GetPackages()
|
||||
|
||||
fmt.Printf("Packages: ")
|
||||
|
||||
for _, pkg := range packages {
|
||||
fmt.Printf("%s\t\t\t\t\t%s\t\t\t\t\t%s\n", pkg.GetArchitecture(), pkg.GetPublisher(), pkg.GetVersion())
|
||||
}
|
||||
//Sample code
|
||||
fmt.Printf(packages[0].Name)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
|
|
|||
Reference in a new issue