-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just exercising this quickly to see where it falls short.
- Loading branch information
Showing
4 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"github.com/spf13/cobra" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
func clientsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "clients", | ||
Short: "manage resources for clients.", | ||
} | ||
|
||
cmd.SetUsageTemplate(resourceUsageTemplate()) | ||
cmd.AddCommand(listClientsCmd(cli)) | ||
|
||
return cmd | ||
} | ||
|
||
func listClientsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "Lists your existing clients", | ||
Long: `$ auth0 client list | ||
Lists your existing clients. To create one try: | ||
$ auth0 client create | ||
`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var list *management.ClientList | ||
|
||
err := ansi.Spinner("Listing clients", func() (err error) { | ||
list, err = cli.api.Client.List() | ||
return err | ||
}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.renderer.ClientList(list.Clients) | ||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package display | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
func (r *Renderer) ClientList(clients []*management.Client) { | ||
r.Heading(ansi.Bold(r.Tenant), "clients") | ||
|
||
for _, c := range clients { | ||
fmt.Fprintf(r.Writer, "- %s (%s)\n", auth0.StringValue(c.Name), appTypeFor(c.AppType)) | ||
fmt.Fprintf(r.Writer, " %s: %s\n", ansi.Italic("ClientID"), ansi.Faint(auth0.StringValue(c.ClientID))) | ||
} | ||
} | ||
|
||
func appTypeFor(v *string) string { | ||
switch { | ||
case v == nil: | ||
return "generic" | ||
|
||
case *v == "non_interactive": | ||
return "machine to machine" | ||
|
||
case *v == "native": | ||
return "native" | ||
|
||
case *v == "spa": | ||
return "single page application" | ||
|
||
case *v == "regular_web": | ||
return "regular web application" | ||
|
||
default: | ||
return *v | ||
} | ||
} |