(f *cmdutil.Factory)
| 42 | } |
| 43 | |
| 44 | func NewCreateCmd(f *cmdutil.Factory) *cobra.Command { |
| 45 | opts := &CreateOptions{ |
| 46 | IO: f.IOStreams, |
| 47 | Config: f.Config, |
| 48 | PrintFlags: cmdutil.NewPrintFlags(), |
| 49 | NewDashboardClient: func(clientID string) *dashboard.Client { |
| 50 | return dashboard.NewClient(clientID) |
| 51 | }, |
| 52 | Browser: pkgopen.Browser, |
| 53 | } |
| 54 | |
| 55 | cmd := &cobra.Command{ |
| 56 | Use: "create", |
| 57 | Short: "Create a new Algolia application", |
| 58 | Long: heredoc.Doc(` |
| 59 | Create a new Algolia application and optionally configure it as a CLI profile. |
| 60 | Requires an active session (run "algolia auth login" first).`), |
| 61 | Example: heredoc.Doc(` |
| 62 | # Create an application interactively (prompts for name, plan, and terms) |
| 63 | $ algolia application create |
| 64 | |
| 65 | # Create a Free application non-interactively |
| 66 | $ algolia application create --name "My App" --region CA --accept-terms |
| 67 | |
| 68 | # Create on a paid plan (requires a payment method on file) |
| 69 | $ algolia application create --name "My App" --region CA --plan grow --accept-terms |
| 70 | |
| 71 | # Create and set the new profile as the default |
| 72 | $ algolia application create --name "My App" --region CA --accept-terms --default |
| 73 | |
| 74 | # Preview what would be created without actually creating it |
| 75 | $ algolia application create --name "My App" --region CA --plan grow --dry-run |
| 76 | `), |
| 77 | Args: validators.NoArgs(), |
| 78 | Annotations: map[string]string{ |
| 79 | "skipAuthCheck": "true", |
| 80 | }, |
| 81 | RunE: func(cmd *cobra.Command, args []string) error { |
| 82 | opts.nameProvided = cmd.Flags().Changed("name") |
| 83 | return runCreateCmd(cmd.Context(), opts) |
| 84 | }, |
| 85 | } |
| 86 | |
| 87 | cmd.Flags().StringVar(&opts.Name, "name", "My First Application", "Name for the application") |
| 88 | cmd.Flags().StringVar(&opts.Region, "region", "", "Region code (e.g. EU, UK, USC, USE, USW)") |
| 89 | cmd.Flags(). |
| 90 | StringVar(&opts.ProfileName, "profile-name", "", "Name for the CLI profile (defaults to app name)") |
| 91 | cmd.Flags(). |
| 92 | StringVar(&opts.Plan, "plan", "", "Self-serve plan to create the application on (free, grow, grow-plus)") |
| 93 | cmd.Flags().BoolVar(&opts.Default, "default", false, "Set the new profile as the default") |
| 94 | cmd.Flags(). |
| 95 | BoolVar(&opts.DryRun, "dry-run", false, "Preview the create request without sending it") |
| 96 | cmd.Flags(). |
| 97 | BoolVarP(&opts.AcceptTerms, "accept-terms", "y", false, "Accept the selected plan's terms of service (required in non-interactive mode)") |
| 98 | |
| 99 | opts.PrintFlags.AddFlags(cmd) |
| 100 | |
| 101 | return cmd |
no test coverage detected