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

Function showUserCmd

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

Source from the content-addressed store, hash-verified

563}
564
565func showUserCmd(cli *cli) *cobra.Command {
566 var inputs struct {
567 ID string
568 }
569
570 cmd := &cobra.Command{
571 Use: "show",
572 Args: cobra.MaximumNArgs(1),
573 Short: "Show an existing user",
574 Long: "Display information about an existing user.",
575 Example: ` auth0 users show
576 auth0 users show <user-id>
577 auth0 users show <user-id> --json
578 auth0 users show <user-id> --json-compact`,
579 RunE: func(cmd *cobra.Command, args []string) error {
580 if len(args) == 0 {
581 if err := userID.Ask(cmd, &inputs.ID); err != nil {
582 return err
583 }
584 } else {
585 inputs.ID = args[0]
586 }
587
588 user := &management.User{ID: &inputs.ID}
589
590 if err := ansi.Waiting(func() error {
591 var err error
592 user, err = cli.api.User.Read(cmd.Context(), inputs.ID)
593 return err
594 }); err != nil {
595 return fmt.Errorf("failed to load user with ID %q: %w", inputs.ID, err)
596 }
597
598 // Get the current connection.
599 conn := stringSliceToCommaSeparatedString(cli.getUserConnection(user))
600 user.Connection = auth0.String(conn)
601
602 // Parse the connection name to get the requireUsername status.
603 u := cli.getConnReqUsername(cmd.Context(), auth0.StringValue(user.Connection))
604 requireUsername := auth0.BoolValue(u)
605
606 cli.renderer.UserShow(user, requireUsername)
607
608 if auth0.BoolValue(user.Blocked) && !cli.json {
609 cli.renderer.Newline()
610 cli.renderer.Warnf("This user is %s and cannot authenticate.\n", ansi.BrightRed("blocked"))
611 }
612
613 return nil
614 },
615 }
616
617 cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
618 cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.")
619
620 return cmd
621}
622

Callers 1

usersCmdFunction · 0.85

Calls 11

WaitingFunction · 0.92
BrightRedFunction · 0.92
ErrorfMethod · 0.80
getUserConnectionMethod · 0.80
getConnReqUsernameMethod · 0.80
UserShowMethod · 0.80
NewlineMethod · 0.80
WarnfMethod · 0.80
ReadMethod · 0.65
AskMethod · 0.45

Tested by

no test coverage detected