MCPcopy Create free account
hub / github.com/auth0/auth0-cli / resolveSetupInputs

Function resolveSetupInputs

internal/cli/quickstarts.go:1298–1355  ·  view source on GitHub ↗

resolveSetupInputs validates and fills missing fields on inputs by prompting the user where needed. It returns the updated inputs, whether a build tool was auto-selected, and any error encountered.

(cmd *cobra.Command, inputs *SetupInputs)

Source from the content-addressed store, hash-verified

1296// where needed. It returns the updated inputs, whether a build tool was auto-selected,
1297// and any error encountered.
1298func resolveSetupInputs(cmd *cobra.Command, inputs *SetupInputs) (bool, error) {
1299 // Validate --type if provided.
1300 validTypes := []string{"spa", "regular", "native", "m2m"}
1301 if inputs.Type != "" && !slices.Contains(validTypes, inputs.Type) {
1302 return false, fmt.Errorf(
1303 "invalid --type %q: must be one of %s",
1304 inputs.Type, strings.Join(validTypes, ", "),
1305 )
1306 }
1307
1308 // Prompt for --type if not provided.
1309 if inputs.Type == "" {
1310 defaultType := "spa"
1311 if err := setupType.Select(cmd, &inputs.Type, validTypes, &defaultType); err != nil {
1312 return false, fmt.Errorf("failed to select application type: %w", err)
1313 }
1314 }
1315
1316 // M2M apps have no framework, port, or callback URLs.
1317 if inputs.Type == "m2m" {
1318 return false, nil
1319 }
1320
1321 // Prompt for --framework filtered to the selected type.
1322 if inputs.Framework == "" {
1323 frameworks := frameworksForType(inputs.Type)
1324 if len(frameworks) == 0 {
1325 return false, fmt.Errorf("no frameworks available for type %q", inputs.Type)
1326 }
1327 if err := setupFramework.Select(cmd, &inputs.Framework, frameworks, &frameworks[0]); err != nil {
1328 return false, fmt.Errorf("failed to select framework: %w", err)
1329 }
1330 }
1331
1332 // Resolve port from framework default before prompting.
1333 // Port stays 0 for native apps (react-native, expo, flutter) - no port needed.
1334 if inputs.Port == 0 {
1335 inputs.Port = defaultPortForFramework(inputs.Framework)
1336 }
1337
1338 // If no explicit build tool and the "none" variant doesn't exist, resolve the best
1339 // supported build tool from the pre-built FrameworkBuildTools map.
1340 wasAutoSelected := false
1341 if inputs.BuildTool == "" || inputs.BuildTool == "none" {
1342 if _, exists := auth0.QuickstartConfigs[fmt.Sprintf("%s:%s:none", inputs.Type, inputs.Framework)]; !exists {
1343 if tools := auth0.FrameworkBuildTools[inputs.Type+":"+inputs.Framework]; len(tools) > 0 {
1344 inputs.BuildTool = tools[0]
1345 wasAutoSelected = true
1346 } else {
1347 inputs.BuildTool = "none"
1348 }
1349 } else {
1350 inputs.BuildTool = "none"
1351 }
1352 }
1353
1354 return wasAutoSelected, nil
1355}

Callers 1

getQuickstartConfigKeyFunction · 0.85

Calls 4

frameworksForTypeFunction · 0.85
defaultPortForFrameworkFunction · 0.85
ErrorfMethod · 0.80
SelectMethod · 0.80

Tested by

no test coverage detected