func wrap(f interface{}) func(*cli.Context) { return func(ctx *cli.Context) { if ctx.GlobalBool("debug") { log.SetOutputLevel(log.Ldebug) } sockPath := filepath.Join(GOSUV_HOME, "gosuv.sock") if err := testConnection("unix", sockPath); err != nil { log.Fatal(err) } conn, err := connect(ctx) if err != nil { log.Fatal(err) } defer conn.Close() programClient := pb.NewProgramClient(conn) gosuvClient := pb.NewGoSuvClient(conn) inj := inject.New() inj.Map(programClient) inj.Map(gosuvClient) inj.Map(ctx) inj.Invoke(f) } }
func StartAction(ctx *cli.Context) { conn, err := connect(ctx) if err != nil { log.Fatal(err) } defer conn.Close() name := ctx.Args().First() client := pb.NewProgramClient(conn) res, err := client.Start(context.Background(), &pb.Request{Name: name}) if err != nil { Errorf("ERR: %#v\n", err) } fmt.Println(res.Message) }