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
|
package Commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"google.golang.org/grpc"
|
|
||||||
"lpm-cli/Lotus"
|
"lpm-cli/Lotus"
|
||||||
proto "lpm-cli/Proto/lpm/go"
|
"lpm-cli/ProtoHandler"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSearchCommand() *cli.Command {
|
func NewSearchCommand() *cli.Command {
|
||||||
|
|
@ -21,31 +18,10 @@ func NewSearchCommand() *cli.Command {
|
||||||
HelpName: "search",
|
HelpName: "search",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
|
||||||
//TODO Remove Hardcoded addr
|
packages := ProtoHandler.SearchPackages("a platform", []string{"amd64", "i386"}, "chrome")
|
||||||
conn, err := grpc.Dial("faf-notebook2:9090", grpc.WithInsecure())
|
|
||||||
if err != nil{
|
|
||||||
logger.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer conn.Close()
|
//Sample code
|
||||||
|
fmt.Printf(packages[0].Name)
|
||||||
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())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Reference in a new issue