Update retrieves the command to tools Keploy
(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)
| 18 | |
| 19 | // Update retrieves the command to tools Keploy |
| 20 | func Update(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command { |
| 21 | var updateCmd = &cobra.Command{ |
| 22 | Use: "update", |
| 23 | Short: "Update Keploy ", |
| 24 | Example: "keploy update", |
| 25 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 26 | disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi")) |
| 27 | provider.PrintLogo(os.Stdout, disableAnsi) |
| 28 | svc, err := serviceFactory.GetService(ctx, "update") |
| 29 | if err != nil { |
| 30 | utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name())) |
| 31 | return nil |
| 32 | } |
| 33 | var tools toolsSvc.Service |
| 34 | var ok bool |
| 35 | if tools, ok = svc.(toolsSvc.Service); !ok { |
| 36 | utils.LogError(logger, nil, "service doesn't satisfy tools service interface") |
| 37 | return nil |
| 38 | } |
| 39 | err = tools.Update(ctx) |
| 40 | if err != nil { |
| 41 | utils.LogError(logger, err, "failed to update") |
| 42 | } |
| 43 | return nil |
| 44 | }, |
| 45 | } |
| 46 | if err := cmdConfigurator.AddFlags(updateCmd); err != nil { |
| 47 | utils.LogError(logger, err, "failed to add update cmd flags") |
| 48 | return nil |
| 49 | } |
| 50 | return updateCmd |
| 51 | } |