MCPcopy
hub / github.com/keploy/keploy / Record

Function Record

cli/record.go:17–56  ·  view source on GitHub ↗
(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator)

Source from the content-addressed store, hash-verified

15}
16
17func Record(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
18 var cmd = &cobra.Command{
19 Use: "record",
20 Short: "record the keploy testcases from the API calls",
21 Example: `keploy record -c "/path/to/user/app"`,
22 PreRunE: func(cmd *cobra.Command, _ []string) error {
23 return cmdConfigurator.Validate(ctx, cmd)
24 },
25 RunE: func(cmd *cobra.Command, _ []string) error {
26 svc, err := serviceFactory.GetService(ctx, cmd.Name())
27 if err != nil {
28 utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
29 return nil
30 }
31 var record recordSvc.Service
32 var ok bool
33 if record, ok = svc.(recordSvc.Service); !ok {
34 utils.LogError(logger, nil, "service doesn't satisfy record service interface")
35 return nil
36 }
37
38 err = record.Start(ctx)
39
40 if err != nil {
41 utils.LogError(logger, err, "failed to record")
42 return nil
43 }
44
45 return nil
46 },
47 }
48
49 err := cmdConfigurator.AddFlags(cmd)
50 if err != nil {
51 utils.LogError(logger, err, "failed to add record flags")
52 return nil
53 }
54
55 return cmd
56}

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
LogErrorFunction · 0.92
NameMethod · 0.80
ValidateMethod · 0.65
GetServiceMethod · 0.65
AddFlagsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected