(ctx context.Context, cmd *cli.Command)
| 48 | } |
| 49 | |
| 50 | func commandPull(ctx context.Context, cmd *cli.Command) error { |
| 51 | ce := clienv.FromCLI(cmd) |
| 52 | |
| 53 | if !clienv.PathExists(ce.Path.NhostFolder()) { |
| 54 | return errors.New( //nolint:err113 |
| 55 | "nhost folder not found. Please run `nhost init --remote` first to initialize your project", |
| 56 | ) |
| 57 | } |
| 58 | |
| 59 | skipConfirmation := cmd.Bool(flagYes) |
| 60 | |
| 61 | if !skipConfirmation { |
| 62 | if err := verifyFile(ce, ce.Path.NhostToml()); err != nil { |
| 63 | return err |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | writeSecrets := true |
| 68 | |
| 69 | if !skipConfirmation { |
| 70 | if err := verifyFile(ce, ce.Path.Secrets()); err != nil { |
| 71 | writeSecrets = false |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | proj, err := ce.GetAppInfo(ctx, cmd.String(flagSubdomain)) |
| 76 | if err != nil { |
| 77 | return fmt.Errorf("failed to get app info: %w", err) |
| 78 | } |
| 79 | |
| 80 | _, err = Pull(ctx, ce, proj, writeSecrets) |
| 81 | |
| 82 | return err |
| 83 | } |
| 84 | |
| 85 | func verifyFile(ce *clienv.CliEnv, name string) error { |
| 86 | if clienv.PathExists(name) { |
nothing calls this directly
no test coverage detected