diff --git a/code/golang/internal/algorithms/search/poison/poison_fancy.go b/code/golang/internal/algorithms/search/poison/poison_fancy.go index 0bc2acd..7f825c6 100644 --- a/code/golang/internal/algorithms/search/poison/poison_fancy.go +++ b/code/golang/internal/algorithms/search/poison/poison_fancy.go @@ -7,6 +7,7 @@ package poison import ( "fmt" + "ads/internal/core/logging" "ads/internal/core/metrics" "ads/internal/core/utils" "ads/internal/setup" @@ -65,6 +66,7 @@ func FancyFindPoison(input_L []int) (int, error) { // Prechecks: if setup.AppConfigPerformChecks() { + logging.LogDebug("hier1a") err = preChecks(input_L) if err != nil { break diff --git a/code/golang/internal/endpoints/endpoints_it.go b/code/golang/internal/endpoints/endpoints_it.go index 032d6cf..254a87f 100644 --- a/code/golang/internal/endpoints/endpoints_it.go +++ b/code/golang/internal/endpoints/endpoints_it.go @@ -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 } diff --git a/code/golang/internal/menus/menus.go b/code/golang/internal/menus/menus.go index fba1bbb..a3a0a02 100644 --- a/code/golang/internal/menus/menus.go +++ b/code/golang/internal/menus/menus.go @@ -172,9 +172,9 @@ func (query *PromptValueQuery) Prompt() (bool, error) { if query.Requirements != nil && len(*query.Requirements) > 0 { if len(*query.Requirements) == 1 { requirement := (*query.Requirements)[0] - lines = append(lines, fmt.Sprintf(" \033[3;4mInput muss erfüllen:\033[0m \033[2m%s\033[0m", requirement)) + lines = append(lines, fmt.Sprintf(" \033[3;4mAnforderung(en) auf Input:\033[0m \033[2m%s\033[0m", requirement)) } else { - lines = append(lines, fmt.Sprintf(" \033[3;4mInput muss erfüllen:\033[0m")) + lines = append(lines, fmt.Sprintf(" \033[3;4mAnforderung(en) auf Input:\033[0m")) for _, requirement := range *query.Requirements { lines = append(lines, fmt.Sprintf(" - \033[2m%s\033[0m", requirement)) } diff --git a/code/golang/internal/setup/setup_appconfig.go b/code/golang/internal/setup/setup_appconfig.go index 6522261..d440bbd 100644 --- a/code/golang/internal/setup/setup_appconfig.go +++ b/code/golang/internal/setup/setup_appconfig.go @@ -17,7 +17,7 @@ import ( var AppConfig = types.AppConfig{} /* ---------------------------------------------------------------- * - * METHODS + * METHODS getters * ---------------------------------------------------------------- */ // Extrahiert Inhalte einer YAML Config und parset dies als Struktur @@ -38,3 +38,19 @@ func AppConfigShowMetrics() bool { func AppConfigPerformChecks() bool { return AppConfig.Options.Checks } + +/* ---------------------------------------------------------------- * + * METHODS setters + * ---------------------------------------------------------------- */ + +func SetAppConfigFancyMode(value bool) { + AppConfig.Options.Display = value +} + +func SetAppConfigShowMetrics(value bool) { + AppConfig.Options.Metrics = value +} + +func SetAppConfigPerformChecks(value bool) { + AppConfig.Options.Checks = value +} diff --git a/code/golang/main.go b/code/golang/main.go index 03e7af9..36bfa7f 100644 --- a/code/golang/main.go +++ b/code/golang/main.go @@ -38,6 +38,10 @@ var ( func main() { var err error var arguments *types.CliArguments + var ( + cmdMissing bool + showChecks bool + ) // assets festlegen setup.Res = res @@ -45,9 +49,10 @@ func main() { // cli arguments parsen arguments, err = cli.ParseCli(os.Args) - cmdMissing := cli.ParseCliCommandMissing(err) + cmdMissing = cli.ParseCliCommandMissing(err) // initialisiere basic optionen wie Logging + showChecks = false if err == nil { quiet := arguments.QuietModeOn() if arguments.InteractiveMode() { @@ -56,16 +61,12 @@ func main() { logging.SetQuietMode(quiet) logging.SetDebugMode(arguments.DebugModeOn()) logging.SetAnsiMode(arguments.ShowColour()) + showChecks = arguments.ShowChecks() } // app config (intern) intialisieren - if err == nil { - err = setup.AppConfigInitialise() - } - - if err == nil { - setup.AppConfig.Options.Checks = arguments.ShowChecks() - } + err = setup.AppConfigInitialise() + setup.SetAppConfigPerformChecks(showChecks) if err == nil { if arguments.ModeVersion.Happened() {