MCPcopy Create free account
hub / github.com/auth0/auth0-cli / deleteUserCmd

Function deleteUserCmd

internal/cli/users.go:623–673  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

621}
622
623func deleteUserCmd(cli *cli) *cobra.Command {
624 cmd := &cobra.Command{
625 Use: "delete",
626 Aliases: []string{"rm"},
627 Short: "Delete a user",
628 Long: "Delete a user.\n\n" +
629 "To delete interactively, use `auth0 users delete` with no arguments.\n\n" +
630 "To delete non-interactively, supply the user id and the `--force` flag to skip confirmation.",
631 Example: ` auth0 users delete
632 auth0 users rm
633 auth0 users delete <user-id>
634 auth0 users delete <user-id> --force
635 auth0 users delete <user-id> <user-id2> <user-idn>
636 auth0 users delete <user-id> <user-id2> <user-idn> --force`,
637 RunE: func(cmd *cobra.Command, args []string) error {
638 var ids []string
639 if len(args) == 0 {
640 var id string
641 if err := userID.Ask(cmd, &id); err != nil {
642 return err
643 }
644 ids = append(ids, id)
645 } else {
646 ids = args
647 }
648
649 if !cli.force && canPrompt(cmd) {
650 if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
651 return nil
652 }
653 }
654
655 return ansi.ProgressBar("Deleting user(s)", ids, func(_ int, id string) error {
656 if id != "" {
657 if _, err := cli.api.User.Read(cmd.Context(), id); err != nil {
658 return fmt.Errorf("failed to delete user with ID %q: %w", id, err)
659 }
660
661 if err := cli.api.User.Delete(cmd.Context(), id); err != nil {
662 return fmt.Errorf("failed to delete user with ID %q: %w", id, err)
663 }
664 }
665 return nil
666 })
667 },
668 }
669
670 cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.")
671
672 return cmd
673}
674
675func updateUserCmd(cli *cli) *cobra.Command {
676 var (

Callers 1

usersCmdFunction · 0.85

Calls 7

ConfirmFunction · 0.92
ProgressBarFunction · 0.92
canPromptFunction · 0.85
ErrorfMethod · 0.80
ReadMethod · 0.65
DeleteMethod · 0.65
AskMethod · 0.45

Tested by

no test coverage detected