|
|
@ -20,10 +20,12 @@ func Configure() (*SetupData, error) { |
|
|
|
|
|
|
|
|
|
|
|
data.Config, err = Load() |
|
|
|
data.Config, err = Load() |
|
|
|
var action string |
|
|
|
var action string |
|
|
|
|
|
|
|
isNewCfg := false |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
fmt.Println("No configuration yet. Creating new.") |
|
|
|
fmt.Println("No configuration yet. Creating new.") |
|
|
|
data.Config = New() |
|
|
|
data.Config = New() |
|
|
|
action = "generate" |
|
|
|
action = "generate" |
|
|
|
|
|
|
|
isNewCfg = true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fmt.Println("Configuration loaded.") |
|
|
|
fmt.Println("Configuration loaded.") |
|
|
|
action = "update" |
|
|
|
action = "update" |
|
|
@ -126,6 +128,20 @@ func Configure() (*SetupData, error) { |
|
|
|
title(" Database setup ") |
|
|
|
title(" Database setup ") |
|
|
|
fmt.Println() |
|
|
|
fmt.Println() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selPrompt = promptui.Select{ |
|
|
|
|
|
|
|
Templates: selTmpls, |
|
|
|
|
|
|
|
Label: "Database driver", |
|
|
|
|
|
|
|
Items: []string{"MySQL", "SQLite"}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sel, _, err := selPrompt.Run() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return data, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sel == 0 { |
|
|
|
|
|
|
|
// Configure for MySQL
|
|
|
|
|
|
|
|
data.Config.UseMySQL(isNewCfg) |
|
|
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
prompt = promptui.Prompt{ |
|
|
|
Templates: tmpls, |
|
|
|
Templates: tmpls, |
|
|
|
Label: "Username", |
|
|
|
Label: "Username", |
|
|
@ -182,6 +198,21 @@ func Configure() (*SetupData, error) { |
|
|
|
return data, err |
|
|
|
return data, err |
|
|
|
} |
|
|
|
} |
|
|
|
data.Config.Database.Port, _ = strconv.Atoi(dbPort) // Ignore error, as we've already validated number
|
|
|
|
data.Config.Database.Port, _ = strconv.Atoi(dbPort) // Ignore error, as we've already validated number
|
|
|
|
|
|
|
|
} else if sel == 1 { |
|
|
|
|
|
|
|
// Configure for SQLite
|
|
|
|
|
|
|
|
data.Config.UseSQLite(isNewCfg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
|
|
|
Templates: tmpls, |
|
|
|
|
|
|
|
Label: "Filename", |
|
|
|
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
|
|
|
Default: data.Config.Database.FileName, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
data.Config.Database.FileName, err = prompt.Run() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return data, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println() |
|
|
|
fmt.Println() |
|
|
|
title(" App setup ") |
|
|
|
title(" App setup ") |
|
|
|