func deleteCmd(c *cli.Context) { if c.NArg() > 0 && c.IsSet("spec") { cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage()) } if !(c.NArg() == 1 || (c.NArg() == 0 && c.IsSet("spec"))) { cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage()) } var deleteSpec *utils.SpecFiles if c.IsSet("spec") { var err error deleteSpec, err = getDeleteSpec(c) cliutils.ExitOnErr(err) } else { deleteSpec = createDefaultDeleteSpec(c) } flags, err := createDeleteFlags(c) cliutils.ExitOnErr(err) if !c.Bool("quiet") { pathsToDelete, err := commands.GetPathsToDelete(deleteSpec, flags) cliutils.ExitOnErr(err) if len(pathsToDelete) < 1 { return } for _, v := range pathsToDelete { fmt.Println(" " + v.GetFullUrl()) } var confirm string fmt.Print("Are you sure you want to delete the above paths? (y/n): ") fmt.Scanln(&confirm) if !cliutils.ConfirmAnswer(confirm) { return } err = commands.DeleteFiles(pathsToDelete, flags) cliutils.ExitOnErr(err) } else { err = commands.Delete(deleteSpec, flags) cliutils.ExitOnErr(err) } }
func cleanArtifactory() { deleteFlags := new(commands.DeleteFlags) deleteFlags.ArtDetails = artifactoryDetails deleteSpec, _ := utils.CreateSpecFromFile(tests.GetFilePath(tests.DeleteSpec)) commands.Delete(deleteSpec, deleteFlags) }