MCPcopy Create free account
hub / github.com/ddev/ddev / AppTypePrompt

Method AppTypePrompt

pkg/ddevapp/config.go:1587–1616  ·  view source on GitHub ↗

AppTypePrompt handles the Type workflow.

()

Source from the content-addressed store, hash-verified

1585
1586// AppTypePrompt handles the Type workflow.
1587func (app *DdevApp) AppTypePrompt() error {
1588 // First, see if we can auto detect what kind of site it is so we can set a sane default.
1589 detectedAppType := app.DetectAppType()
1590
1591 // If we found an application type set it and inform the user.
1592 util.Success("Found a %s codebase at %s.", detectedAppType, app.GetAbsDocroot(false))
1593
1594 validAppTypes := strings.Join(GetValidAppTypes(), ", ")
1595 typePrompt := "Project Type [%s] (%s): "
1596
1597 defaultAppType := app.Type
1598 if app.Type == nodeps.AppTypeNone || !IsValidAppType(app.Type) {
1599 defaultAppType = detectedAppType
1600 }
1601
1602 appType := ""
1603
1604 for {
1605 fmt.Printf(typePrompt, validAppTypes, defaultAppType)
1606 appType = strings.ToLower(util.GetInput(defaultAppType))
1607 if IsValidAppType(appType) {
1608 break
1609 }
1610 output.UserOut.Print(util.ColorizeText(fmt.Sprintf("'%s' is not a valid project type", appType), "yellow"))
1611 }
1612
1613 app.Type = appType
1614
1615 return nil
1616}
1617
1618// PrepDdevDirectory creates a .ddev directory in the current working directory
1619func PrepDdevDirectory(app *DdevApp) error {

Callers 3

PromptForConfigMethod · 0.95
TestConfigOverrideActionFunction · 0.80

Calls 7

DetectAppTypeMethod · 0.95
GetAbsDocrootMethod · 0.95
SuccessFunction · 0.92
GetInputFunction · 0.92
ColorizeTextFunction · 0.92
GetValidAppTypesFunction · 0.85
IsValidAppTypeFunction · 0.85

Tested by 2

TestConfigOverrideActionFunction · 0.64