diff --git a/internal/cli/clients.go b/internal/cli/clients.go index 633b7ed8a..ebeb33227 100644 --- a/internal/cli/clients.go +++ b/internal/cli/clients.go @@ -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 } diff --git a/internal/cli/clients_quickstart.go b/internal/cli/quickstart.go similarity index 83% rename from internal/cli/clients_quickstart.go rename to internal/cli/quickstart.go index 5141e55be..c1f1377d8 100644 --- a/internal/cli/clients_quickstart.go +++ b/internal/cli/quickstart.go @@ -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 --client-id `, + Use: "download", + Short: "Download a specific type and tech stack for quick starts", + Long: `auth0 quickstart download --type --client-id --stack `, RunE: func(cmd *cobra.Command, args []string) error { client, err := cli.api.Client.Read(flags.ClientID) if err != nil { @@ -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 { @@ -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 } @@ -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"` diff --git a/internal/cli/root.go b/internal/cli/root.go index 321269639..6772d7d47 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -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))