master > master: code go - logic flaw behoben (Ursache war handling von errors im main.go)

This commit is contained in:
RD
2021-11-03 19:29:06 +01:00
parent 47414d6d60
commit be9ce8bb82
5 changed files with 67 additions and 15 deletions

View File

@@ -66,6 +66,7 @@ var menuSettings = menus.Menu{
{Label: "Aktueller Zustand", Action: actionShowSettings},
{Label: "Farbenmodus", Submenu: &menuColourMode},
{Label: "Debugmodus", Submenu: &menuDebugMode},
{Label: "Pre / Postchecking", Submenu: &menuPrePostChecking},
},
},
Default: -1,
@@ -103,6 +104,22 @@ var menuDebugMode = menus.Menu{
Default: 1,
}
var menuPrePostChecking = menus.Menu{
ForceReturn: true,
Path: []string{"Hauptmenü", "Einstellungen", "Pre/Postchecking"},
PromptMessages: []string{
"Sollen Inputs+Outputs bei Algorithmenausführungen geprüft werden?",
"Option für den Pre/Postchecking wählen:",
},
Options: [][]menus.MenuOption{
{
{Label: "ein", Action: actionPrePostCheckingOn},
{Label: "aus", Action: actionPrePostCheckingOff},
},
},
Default: 1,
}
var menuSearchAlgorithms = menus.Menu{
Path: []string{"Hauptmenü", "Suchalgorithmen"},
PromptMessages: []string{
@@ -183,6 +200,16 @@ func actionDebugModeOff() (bool, error) {
return false, nil
}
func actionPrePostCheckingOn() (bool, error) {
setup.SetAppConfigPerformChecks(true)
return false, nil
}
func actionPrePostCheckingOff() (bool, error) {
setup.SetAppConfigPerformChecks(false)
return false, nil
}
/* ---------------------------------------------------------------- *
* ACTIONS - Algorithmen
* ---------------------------------------------------------------- */
@@ -311,7 +338,7 @@ func actionAlgorithmSearchJumpExp() (bool, error) {
}
func actionAlgorithmSearchPoison() (bool, error) {
input_L, cancel, err := PromptInputListOfInt("L", "Liste von Werten", []string{
input_L, cancel, err := PromptInputListOfZeroOnes("L", "Liste von Werten", []string{
"muss genau eine 1 enthalten",
})
if cancel || err != nil {
@@ -319,7 +346,6 @@ func actionAlgorithmSearchPoison() (bool, error) {
}
setup.DisplayStartOfCaseBlank()
algorithm_search_poison.FancyFindPoison(input_L)
logging.Prompt("hallo")
setup.DisplayEndOfCase()
return cancel, nil
}
@@ -415,8 +441,9 @@ func PromptInputListOfInt(name string, descr string, requirements []string) ([]i
}
func PromptInputListOfZeroOnes(name string, descr string, requirements []string) ([]int, bool, error) {
var values = []int{}
type responseType struct {
Response []int `yaml:"response"`
Response []uint8 `yaml:"response"`
}
var response = responseType{}
var query = menus.PromptValueQuery{
@@ -431,5 +458,11 @@ func PromptInputListOfZeroOnes(name string, descr string, requirements []string)
Response: &response,
}
cancel, err := query.Prompt()
return response.Response, cancel, err
// konvertiere in int
if !cancel && err != nil {
for _, x := range response.Response {
values = append(values, int(x))
}
}
return values, cancel, err
}