diff --git a/internal/cli/root.go b/internal/cli/root.go index e4d39d2ff..b6d467058 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -86,6 +86,7 @@ func buildRootCmd(cli *cli) *cobra.Command { PersistentPreRunE: func(cmd *cobra.Command, args []string) error { ansi.Initialize(cli.noColor) prepareInteractivity(cmd) + cli.configureRenderer() if !commandRequiresAuthentication(cmd.CommandPath()) { return nil @@ -105,7 +106,6 @@ func buildRootCmd(cli *cli) *cobra.Command { return err } - cli.configureRenderer() return nil }, } diff --git a/internal/display/tenants.go b/internal/display/tenants.go index e6faa165f..69f2802a9 100644 --- a/internal/display/tenants.go +++ b/internal/display/tenants.go @@ -1,16 +1,27 @@ package display +import "github.com/auth0/auth0-cli/internal/ansi" + type tenantView struct { - Name string - raw interface{} + Active bool + Name string + raw interface{} } func (v *tenantView) AsTableHeader() []string { - return []string{"Available tenants"} + return []string{"Active", "Tenant"} } func (v *tenantView) AsTableRow() []string { - return []string{v.Name} + activeText := "" + if v.Active { + activeText = ansi.Green("→") + } + + return []string{ + activeText, + v.Name, + } } func (v *tenantView) Object() interface{} { @@ -18,8 +29,6 @@ func (v *tenantView) Object() interface{} { } func (r *Renderer) TenantList(data []string) { - r.Heading() - if len(data) == 0 { r.EmptyState("tenants", "Use 'auth0 login' to add one") return @@ -28,8 +37,9 @@ func (r *Renderer) TenantList(data []string) { var results []View for _, item := range data { results = append(results, &tenantView{ - Name: item, - raw: item, + Active: item == r.Tenant, + Name: item, + raw: item, }) } diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index d3076199c..4461a0320 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -3,9 +3,6 @@ config: retries: 1 tests: - auth0 tenants list: - exit-code: 0 - auth0 completion bash: exit-code: 0 @@ -100,6 +97,15 @@ tests: - STAGE_PRE_USER_REGISTRATION_RATE exit-code: 0 + tenants list: + command: auth0 tenants list + exit-code: 0 + stdout: + contains: + - ACTIVE + - TENANT + - → + tenants use: command: auth0 tenants use $AUTH0_DOMAIN exit-code: 0