(cmd *cobra.Command)
| 165 | } |
| 166 | |
| 167 | func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error { |
| 168 | //sets the displayment of flag-related errors |
| 169 | cmd.SilenceErrors = true |
| 170 | cmd.SetFlagErrorFunc(func(_ *cobra.Command, err error) error { |
| 171 | PrintLogo(os.Stdout, true) |
| 172 | color.Red(fmt.Sprintf("❌ error: %v", err)) |
| 173 | fmt.Println() |
| 174 | return err |
| 175 | }) |
| 176 | |
| 177 | //add flags |
| 178 | var err error |
| 179 | cmd.Flags().SetNormalizeFunc(aliasNormalizeFunc) |
| 180 | cmd.Flags().String("configPath", ".", "Path to the local directory where keploy configuration file is stored") |
| 181 | |
| 182 | switch cmd.Name() { |
| 183 | case "generate", "download": |
| 184 | cmd.Flags().StringSliceP("services", "s", c.cfg.Contract.Services, "Specify the services for which to generate/download contracts") |
| 185 | cmd.Flags().StringSliceP("tests", "t", c.cfg.Contract.Tests, "Specify the tests for which to generate/download contracts") |
| 186 | cmd.Flags().StringP("path", "p", ".", "Specify the path to generate/download contracts") |
| 187 | if cmd.Name() == "download" { // for downloading contracts |
| 188 | cmd.Flags().String("driven", c.cfg.Contract.Driven, "Specify the path to download contracts") |
| 189 | } |
| 190 | |
| 191 | case "update", "export", "import": |
| 192 | return nil |
| 193 | case "postman": |
| 194 | cmd.Flags().StringP("path", "p", "", "Specify the path to the postman collection") |
| 195 | cmd.Flags().String("base-path", c.cfg.Test.BasePath, "basePath to hit the server while importing keploy tests from postman collection with no response in the collection") |
| 196 | case "normalize": |
| 197 | cmd.Flags().StringP("path", "p", ".", "Path to local directory where generated testcases/mocks/reports are stored") |
| 198 | cmd.Flags().String("test-run", "", "Test Run to be normalized") |
| 199 | cmd.Flags().String("tests", "", "Test Sets to be normalized") |
| 200 | cmd.Flags().Bool("allow-high-risk", false, "Allow normalization of high-risk test failures") |
| 201 | case "config": |
| 202 | cmd.Flags().StringP("path", "p", ".", "Path to local directory where generated config is stored") |
| 203 | cmd.Flags().Bool("generate", false, "Generate a new keploy configuration file") |
| 204 | case "templatize": |
| 205 | cmd.Flags().StringP("path", "p", ".", "Path to local directory where generated testcases/mocks are stored") |
| 206 | cmd.Flags().StringSliceP("testsets", "t", c.cfg.Templatize.TestSets, "Testsets to run e.g. --testsets \"test-set-1, test-set-2\"") |
| 207 | case "record", "test": |
| 208 | if cmd.Parent() != nil && cmd.Parent().Name() == "contract" { |
| 209 | cmd.Flags().StringSliceP("services", "s", c.cfg.Contract.Services, "Specify the services for which to generate contracts") |
| 210 | cmd.Flags().StringP("path", "p", ".", "Specify the path to generate contracts") |
| 211 | cmd.Flags().Bool("download", true, "Specify whether to download contracts or not") |
| 212 | cmd.Flags().Bool("generate", true, "Specify whether to generate schemas for the current service or not") |
| 213 | cmd.Flags().String("driven", c.cfg.Contract.Driven, "Specify the driven flag to validate contracts") |
| 214 | return nil |
| 215 | } |
| 216 | |
| 217 | cmd.Flags().Bool("sync", c.cfg.Record.Synchronous, "Synchronous recording of testcases") |
| 218 | // `keploy record` needs --disable-mapping locally so the host |
| 219 | // CLI has an explicit override path. The resolved host value is |
| 220 | // forwarded to the spawned agent (docker / k8s sidecar / native |
| 221 | // subprocess) via the --disable-mapping arg the orchestrator |
| 222 | // appends. Without this flag here, the host can only inherit |
| 223 | // the value from keploy.yml or fall back to the default in |
| 224 | // config/default.go (mapping enabled). That's fine for fresh |
nothing calls this directly
no test coverage detected