Skip to content

Commit

Permalink
Merge pull request #80 from auth0/move-quickstart-to-root
Browse files Browse the repository at this point in the history
This just moves quickstart to root and adds an alias
  • Loading branch information
cyx authored Jan 27, 2021
2 parents 2a03272 + 570216c commit a24b55e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion internal/cli/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func clientsCmd(cli *cli) *cobra.Command {
cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(clientsListCmd(cli))
cmd.AddCommand(clientsCreateCmd(cli))
cmd.AddCommand(clientsQuickstartCmd(cli))

return cmd
}
Expand Down
29 changes: 22 additions & 7 deletions internal/cli/clients_quickstart.go → internal/cli/quickstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@ import (
"gopkg.in/auth0.v5/management"
)

func clientsQuickstartCmd(cli *cli) *cobra.Command {
func quickstartCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "quickstart",
Short: "Quickstart support for getting bootstrapped",
Aliases: []string{"qs"},
}

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(quickstartDownloadCmd(cli))

return cmd
}

func quickstartDownloadCmd(cli *cli) *cobra.Command {
var flags struct {
ClientID string
Type string
Stack string
}

cmd := &cobra.Command{
Use: "quickstart",
Short: "Clients quickstart support for getting bootstrapped.",
Long: `$ auth0 clients quickstart --type <type> --client-id <client-id>`,
Use: "download",
Short: "Download a specific type and tech stack for quick starts",
Long: `auth0 quickstart download --type <type> --client-id <client-id> --stack <stack>`,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cli.api.Client.Read(flags.ClientID)
if err != nil {
Expand All @@ -47,7 +61,7 @@ func clientsQuickstartCmd(cli *cli) *cobra.Command {
}

err = ansi.Spinner("Downloading quickstart", func() error {
return downloadQuickStart(context.TODO(), cli, client, target)
return downloadQuickStart(context.TODO(), cli, client, flags.Stack, target)
})

if err != nil {
Expand All @@ -62,7 +76,8 @@ func clientsQuickstartCmd(cli *cli) *cobra.Command {
cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.Flags().StringVar(&flags.ClientID, "client-id", "", "ID of the client.")
cmd.Flags().StringVarP(&flags.Type, "type", "t", "", "Type of the quickstart to download.")
mustRequireFlags(cmd, "client-id", "type")
cmd.Flags().StringVarP(&flags.Stack, "stack", "s", "", "Tech stack of the quickstart to use.")
mustRequireFlags(cmd, "client-id", "type", "stack")

return cmd
}
Expand All @@ -74,7 +89,7 @@ const (
quickstartDefaultCallbackURL = `https://YOUR_APP/callback`
)

func downloadQuickStart(ctx context.Context, cli *cli, client *management.Client, target string) error {
func downloadQuickStart(ctx context.Context, cli *cli, client *management.Client, target, stack string) error {
var payload struct {
Branch string `json:"branch"`
Org string `json:"org"`
Expand Down
1 change: 1 addition & 0 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func Execute() {
// order of the comamnds here matters
// so add new commands in a place that reflect its relevance or relation with other commands:
rootCmd.AddCommand(loginCmd(cli))
rootCmd.AddCommand(quickstartCmd(cli))
rootCmd.AddCommand(clientsCmd(cli))
rootCmd.AddCommand(apisCmd(cli))
rootCmd.AddCommand(tryLoginCmd(cli))
Expand Down

0 comments on commit a24b55e

Please sign in to comment.