(ch *cmdutil.Helper)
| 15 | ) |
| 16 | |
| 17 | func PullCmd(ch *cmdutil.Helper) *cobra.Command { |
| 18 | var projectPath, projectName, environment string |
| 19 | |
| 20 | pullCmd := &cobra.Command{ |
| 21 | Use: "pull [<project-name>]", |
| 22 | Short: "Pull cloud credentials into local .env file", |
| 23 | RunE: func(cmd *cobra.Command, args []string) error { |
| 24 | // If projectPath is provided, normalize it |
| 25 | if projectPath != "" { |
| 26 | var err error |
| 27 | projectPath, err = normalizeProjectPath(projectPath) |
| 28 | if err != nil { |
| 29 | return err |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if len(args) > 0 { |
| 34 | projectName = args[0] |
| 35 | } |
| 36 | |
| 37 | // Fetch the project variables from the cloud |
| 38 | return PullVars(cmd.Context(), ch, projectPath, projectName, environment, true) |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | pullCmd.Flags().StringVar(&projectPath, "path", ".", "Project directory") |
| 43 | pullCmd.Flags().StringVar(&projectName, "project", "", "Cloud project name (will attempt to infer from Git remote if not provided)") |
| 44 | pullCmd.Flags().StringVar(&environment, "environment", "dev", "Environment to resolve for (options: dev, prod)") |
| 45 | |
| 46 | return pullCmd |
| 47 | } |
| 48 | |
| 49 | func PullVars(ctx context.Context, ch *cmdutil.Helper, projectPath, projectName, environment string, warnForNoVars bool) error { |
| 50 | // Parse and verify the project directory |
no test coverage detected