(cli *cli)
| 63 | } |
| 64 | |
| 65 | func useTenantCmd(cli *cli) *cobra.Command { |
| 66 | cmd := &cobra.Command{ |
| 67 | Use: "use", |
| 68 | Args: cobra.MaximumNArgs(1), |
| 69 | Short: "Set the active tenant", |
| 70 | Long: "Set the active tenant for the Auth0 CLI.", |
| 71 | Example: ` auth0 tenants use |
| 72 | auth0 tenants use <tenant> |
| 73 | auth0 tenants use "example.us.auth0.com"`, |
| 74 | RunE: func(cmd *cobra.Command, args []string) error { |
| 75 | selectedTenant, err := selectValidTenantFromConfig(cli, cmd, args) |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | if err := cli.Config.SetDefaultTenant(selectedTenant); err != nil { |
| 81 | return fmt.Errorf("failed to set the default tenant: %w", err) |
| 82 | } |
| 83 | |
| 84 | cli.renderer.Infof("Default tenant switched to: %s", selectedTenant) |
| 85 | return nil |
| 86 | }, |
| 87 | } |
| 88 | |
| 89 | return cmd |
| 90 | } |
| 91 | |
| 92 | func openTenantCmd(cli *cli) *cobra.Command { |
| 93 | cmd := &cobra.Command{ |
no test coverage detected