runCreateCmd represents runner for the `create` command.
(cmd *cobra.Command, args []string)
| 36 | |
| 37 | // runCreateCmd represents runner for the `create` command. |
| 38 | func runCreateCmd(cmd *cobra.Command, args []string) error { |
| 39 | // Start message. |
| 40 | cgapp.ShowMessage( |
| 41 | "", |
| 42 | fmt.Sprintf( |
| 43 | "Create a new project via Create Go App CLI v%v...", |
| 44 | registry.CLIVersion, |
| 45 | ), |
| 46 | true, true, |
| 47 | ) |
| 48 | |
| 49 | // Start survey. |
| 50 | if useCustomTemplate { |
| 51 | // Custom survey. |
| 52 | if err := survey.Ask( |
| 53 | registry.CustomCreateQuestions, |
| 54 | &customCreateAnswers, |
| 55 | survey.WithIcons(surveyIconsConfig), |
| 56 | ); err != nil { |
| 57 | return cgapp.ShowError(err.Error()) |
| 58 | } |
| 59 | |
| 60 | // Define variables for better display. |
| 61 | backend = customCreateAnswers.Backend |
| 62 | frontend = customCreateAnswers.Frontend |
| 63 | proxy = customCreateAnswers.Proxy |
| 64 | } else { |
| 65 | // Default survey. |
| 66 | if err := survey.Ask( |
| 67 | registry.CreateQuestions, |
| 68 | &createAnswers, |
| 69 | survey.WithIcons(surveyIconsConfig), |
| 70 | ); err != nil { |
| 71 | return cgapp.ShowError(err.Error()) |
| 72 | } |
| 73 | |
| 74 | // Define variables for better display. |
| 75 | backend = fmt.Sprintf( |
| 76 | "github.com/create-go-app/%v-go-template", |
| 77 | strings.ReplaceAll(createAnswers.Backend, "/", "_"), |
| 78 | ) |
| 79 | frontend = createAnswers.Frontend |
| 80 | proxy = createAnswers.Proxy |
| 81 | } |
| 82 | |
| 83 | // Catch the cancel action (hit "n" in the last question). |
| 84 | if (!createAnswers.AgreeCreation && !useCustomTemplate) || (!customCreateAnswers.AgreeCreation && useCustomTemplate) { |
| 85 | cgapp.ShowMessage( |
| 86 | "", |
| 87 | "Oh no! You said \"no\", so I won't create anything. Hope to see you soon!", |
| 88 | true, true, |
| 89 | ) |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | // Start timer. |
| 94 | startTimer := time.Now() |
| 95 |
nothing calls this directly
no test coverage detected