()
| 23 | ) |
| 24 | |
| 25 | func newOrganizationDeleteCmd() *cobra.Command { |
| 26 | var orgName string |
| 27 | cmd := &cobra.Command{ |
| 28 | Use: "delete", |
| 29 | Short: "Delete an organization", |
| 30 | Long: "Delete an organization. Only organization owners can delete an organization.", |
| 31 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 32 | ctx := cmd.Context() |
| 33 | |
| 34 | fmt.Printf("You are about to delete the organization %q\n", orgName) |
| 35 | fmt.Println("This action will permanently delete the organization and all its data.") |
| 36 | |
| 37 | // Ask for confirmation |
| 38 | if err := confirmDeletion(); err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | if err := action.NewOrganizationDelete(ActionOpts).Run(ctx, orgName); err != nil { |
| 43 | return fmt.Errorf("deleting organization: %w", err) |
| 44 | } |
| 45 | |
| 46 | // Clear local state if we just deleted the current organization |
| 47 | if err := setLocalOrganization(""); err != nil { |
| 48 | return fmt.Errorf("writing config file: %w", err) |
| 49 | } |
| 50 | |
| 51 | logger.Info().Str("organization", orgName).Msg("Organization deleted") |
| 52 | return nil |
| 53 | }, |
| 54 | } |
| 55 | |
| 56 | cmd.Flags().StringVar(&orgName, "name", "", "organization name") |
| 57 | cobra.CheckErr(cmd.MarkFlagRequired("name")) |
| 58 | return cmd |
| 59 | } |
no test coverage detected