MCPcopy
hub / github.com/keploy/keploy / Export

Function Export

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

Source from the content-addressed store, hash-verified

17}
18
19func Export(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {
20
21 var exportCmd = &cobra.Command{
22 Use: "export",
23 Short: "export Keploy tests as postman collection",
24 Example: "keploy export",
25 RunE: func(cmd *cobra.Command, _ []string) error {
26 disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi"))
27 provider.PrintLogo(os.Stdout, disableAnsi)
28 return cmd.Help()
29 },
30 }
31 var postmanCmd = &cobra.Command{
32 Use: "postman",
33 Short: "export Keploy tests as Postman collection",
34 Example: "keploy export postman",
35 RunE: func(cmd *cobra.Command, _ []string) error {
36 disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi"))
37 provider.PrintLogo(os.Stdout, disableAnsi)
38 svc, err := serviceFactory.GetService(ctx, "export")
39 if err != nil {
40 utils.LogError(logger, err, "failed to get service", zap.String("command", cmd.Name()))
41 return nil
42 }
43 var tools toolsSvc.Service
44 var ok bool
45 if tools, ok = svc.(toolsSvc.Service); !ok {
46 utils.LogError(logger, nil, "service doesn't satisfy tools service interface")
47 return nil
48 }
49 err = tools.Export(ctx) // Assuming ExportPostmanCollection is a method in tools service
50 if err != nil {
51 utils.LogError(logger, err, "failed to export Postman collection")
52 }
53 return nil
54 },
55 }
56 exportCmd.AddCommand(postmanCmd)
57
58 if err := cmdConfigurator.AddFlags(exportCmd); err != nil {
59 utils.LogError(logger, err, "failed to add export cmd flags")
60 return nil
61 }
62 return exportCmd
63}

Callers

nothing calls this directly

Calls 7

ExportMethod · 0.95
PrintLogoFunction · 0.92
LogErrorFunction · 0.92
NameMethod · 0.80
GetServiceMethod · 0.65
AddFlagsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected