Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "A brief description of your command", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, PreRunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return utils.ErrNoArgs } return nil }, RunE: func(cmd *cobra.Command, args []string) error { cl, err := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatalf("did not connect: %v", err) } defer cl.Close() c := pb.NewRouteManagerClient(cl) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() r, err := c.AddRoute(ctx, &pb.AddRouteRequest{Destination: "example.com"}) if err != nil { log.Fatalf("could not add route: %v", err) } fmt.Printf("AddRoute Response: %v\n", r) if r.GetError() != nil { fmt.Printf("Business Error: %v\n", r.GetError().String()) } return nil }, }
AddCmd represents the add command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.