Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This just moves quickstart to root and adds an alias #80

Merged
merged 5 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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