(cli *cli)
| 499 | } |
| 500 | |
| 501 | func deleteOrganizationCmd(cli *cli) *cobra.Command { |
| 502 | cmd := &cobra.Command{ |
| 503 | Use: "delete", |
| 504 | Aliases: []string{"rm"}, |
| 505 | Short: "Delete an organization", |
| 506 | Long: "Delete an organization.\n\n" + |
| 507 | "To delete interactively, use `auth0 orgs delete` with no arguments.\n\n" + |
| 508 | "To delete non-interactively, supply the organization id and the `--force` " + |
| 509 | "flag to skip confirmation.", |
| 510 | Example: ` auth0 orgs delete |
| 511 | auth0 orgs rm |
| 512 | auth0 orgs delete <org-id> |
| 513 | auth0 orgs delete <org-id> --force |
| 514 | auth0 orgs delete <org-id> <org-id2> <org-idn> |
| 515 | auth0 orgs delete <org-id> <org-id2> <org-idn> --force`, |
| 516 | RunE: func(cmd *cobra.Command, args []string) error { |
| 517 | var ids []string |
| 518 | if len(args) == 0 { |
| 519 | if err := organizationID.PickMany(cmd, &ids, cli.organizationPickerOptions); err != nil { |
| 520 | return err |
| 521 | } |
| 522 | } else { |
| 523 | ids = args |
| 524 | } |
| 525 | |
| 526 | if !cli.force && canPrompt(cmd) { |
| 527 | if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed { |
| 528 | return nil |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | return ansi.ProgressBar("Deleting organization(s)", ids, func(_ int, id string) error { |
| 533 | if id != "" { |
| 534 | if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil { |
| 535 | return fmt.Errorf("failed to delete organization with ID %q: %w", id, err) |
| 536 | } |
| 537 | |
| 538 | if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil { |
| 539 | return fmt.Errorf("failed to delete organization with ID %q: %w", id, err) |
| 540 | } |
| 541 | } |
| 542 | return nil |
| 543 | }) |
| 544 | }, |
| 545 | } |
| 546 | |
| 547 | cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.") |
| 548 | |
| 549 | return cmd |
| 550 | } |
| 551 | |
| 552 | func openOrganizationCmd(cli *cli) *cobra.Command { |
| 553 | var inputs struct { |
no test coverage detected