Skip to content

Commit

Permalink
Removing flag declarations from tenants file context to login
Browse files Browse the repository at this point in the history
  • Loading branch information
willvedd committed Dec 7, 2022
1 parent 9de4783 commit 57a6864
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
22 changes: 18 additions & 4 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ var (
Help: "Specifies tenant domain when authenticating via client credentials (client ID, client secret)",
IsRequired: false,
}

loginClientID = Flag{
Name: "Client ID",
LongForm: "client-id",
Help: "Client ID of the application.",
IsRequired: true,
}

loginClientSecret = Flag{
Name: "Client Secret",
LongForm: "client-secret",
Help: "Client Secret of the application.",
IsRequired: true,
}
)

type LoginInputs struct {
Expand Down Expand Up @@ -62,8 +76,8 @@ func loginCmd(cli *cli) *cobra.Command {
}

loginTenantDomain.RegisterString(cmd, &inputs.Domain, "")
tenantClientID.RegisterString(cmd, &inputs.ClientID, "")
tenantClientSecret.RegisterString(cmd, &inputs.ClientSecret, "")
loginClientID.RegisterString(cmd, &inputs.ClientID, "")
loginClientSecret.RegisterString(cmd, &inputs.ClientSecret, "")

cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
_ = cmd.Flags().MarkHidden("tenant")
Expand Down Expand Up @@ -183,11 +197,11 @@ func RunLoginAsMachine(ctx context.Context, inputs LoginInputs, cli *cli, cmd *c
return err
}

if err := tenantClientID.Ask(cmd, &inputs.ClientID, nil); err != nil {
if err := loginClientID.Ask(cmd, &inputs.ClientID, nil); err != nil {
return err
}

if err := tenantClientSecret.AskPassword(cmd, &inputs.ClientSecret, nil); err != nil {
if err := loginClientSecret.AskPassword(cmd, &inputs.ClientSecret, nil); err != nil {
return err
}

Expand Down
28 changes: 5 additions & 23 deletions internal/cli/tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,6 @@ import (
"github.com/auth0/auth0-cli/internal/prompt"
)

var (
tenantDomain = Argument{
Name: "Tenant",
Help: "Tenant to select",
}

tenantClientID = Flag{
Name: "Client ID",
LongForm: "client-id",
ShortForm: "i",
Help: "Client ID of the application.",
IsRequired: true,
}

tenantClientSecret = Flag{
Name: "Client Secret",
LongForm: "client-secret",
ShortForm: "s",
Help: "Client Secret of the application.",
IsRequired: true,
}
)

func tenantsCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "tenants",
Expand Down Expand Up @@ -126,6 +103,11 @@ func openTenantCmd(cli *cli) *cobra.Command {
Domain string
}

var tenantDomain = Argument{
Name: "Tenant",
Help: "Tenant to select",
}

cmd := &cobra.Command{
Use: "open",
Args: cobra.MaximumNArgs(1),
Expand Down

0 comments on commit 57a6864

Please sign in to comment.