master > master: code go - logic flaw behoben (Ursache war handling von errors im main.go)
This commit is contained in:
parent
47414d6d60
commit
be9ce8bb82
@ -7,6 +7,7 @@ package poison
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"ads/internal/core/logging"
|
||||||
"ads/internal/core/metrics"
|
"ads/internal/core/metrics"
|
||||||
"ads/internal/core/utils"
|
"ads/internal/core/utils"
|
||||||
"ads/internal/setup"
|
"ads/internal/setup"
|
||||||
@ -65,6 +66,7 @@ func FancyFindPoison(input_L []int) (int, error) {
|
|||||||
|
|
||||||
// Prechecks:
|
// Prechecks:
|
||||||
if setup.AppConfigPerformChecks() {
|
if setup.AppConfigPerformChecks() {
|
||||||
|
logging.LogDebug("hier1a")
|
||||||
err = preChecks(input_L)
|
err = preChecks(input_L)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
@ -66,6 +66,7 @@ var menuSettings = menus.Menu{
|
|||||||
{Label: "Aktueller Zustand", Action: actionShowSettings},
|
{Label: "Aktueller Zustand", Action: actionShowSettings},
|
||||||
{Label: "Farbenmodus", Submenu: &menuColourMode},
|
{Label: "Farbenmodus", Submenu: &menuColourMode},
|
||||||
{Label: "Debugmodus", Submenu: &menuDebugMode},
|
{Label: "Debugmodus", Submenu: &menuDebugMode},
|
||||||
|
{Label: "Pre / Postchecking", Submenu: &menuPrePostChecking},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Default: -1,
|
Default: -1,
|
||||||
@ -103,6 +104,22 @@ var menuDebugMode = menus.Menu{
|
|||||||
Default: 1,
|
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{
|
var menuSearchAlgorithms = menus.Menu{
|
||||||
Path: []string{"Hauptmenü", "Suchalgorithmen"},
|
Path: []string{"Hauptmenü", "Suchalgorithmen"},
|
||||||
PromptMessages: []string{
|
PromptMessages: []string{
|
||||||
@ -183,6 +200,16 @@ func actionDebugModeOff() (bool, error) {
|
|||||||
return false, nil
|
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
|
* ACTIONS - Algorithmen
|
||||||
* ---------------------------------------------------------------- */
|
* ---------------------------------------------------------------- */
|
||||||
@ -311,7 +338,7 @@ func actionAlgorithmSearchJumpExp() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func actionAlgorithmSearchPoison() (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",
|
"muss genau eine 1 enthalten",
|
||||||
})
|
})
|
||||||
if cancel || err != nil {
|
if cancel || err != nil {
|
||||||
@ -319,7 +346,6 @@ func actionAlgorithmSearchPoison() (bool, error) {
|
|||||||
}
|
}
|
||||||
setup.DisplayStartOfCaseBlank()
|
setup.DisplayStartOfCaseBlank()
|
||||||
algorithm_search_poison.FancyFindPoison(input_L)
|
algorithm_search_poison.FancyFindPoison(input_L)
|
||||||
logging.Prompt("hallo")
|
|
||||||
setup.DisplayEndOfCase()
|
setup.DisplayEndOfCase()
|
||||||
return cancel, nil
|
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) {
|
func PromptInputListOfZeroOnes(name string, descr string, requirements []string) ([]int, bool, error) {
|
||||||
|
var values = []int{}
|
||||||
type responseType struct {
|
type responseType struct {
|
||||||
Response []int `yaml:"response"`
|
Response []uint8 `yaml:"response"`
|
||||||
}
|
}
|
||||||
var response = responseType{}
|
var response = responseType{}
|
||||||
var query = menus.PromptValueQuery{
|
var query = menus.PromptValueQuery{
|
||||||
@ -431,5 +458,11 @@ func PromptInputListOfZeroOnes(name string, descr string, requirements []string)
|
|||||||
Response: &response,
|
Response: &response,
|
||||||
}
|
}
|
||||||
cancel, err := query.Prompt()
|
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
|
||||||
}
|
}
|
||||||
|
@ -172,9 +172,9 @@ func (query *PromptValueQuery) Prompt() (bool, error) {
|
|||||||
if query.Requirements != nil && len(*query.Requirements) > 0 {
|
if query.Requirements != nil && len(*query.Requirements) > 0 {
|
||||||
if len(*query.Requirements) == 1 {
|
if len(*query.Requirements) == 1 {
|
||||||
requirement := (*query.Requirements)[0]
|
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 {
|
} 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 {
|
for _, requirement := range *query.Requirements {
|
||||||
lines = append(lines, fmt.Sprintf(" - \033[2m%s\033[0m", requirement))
|
lines = append(lines, fmt.Sprintf(" - \033[2m%s\033[0m", requirement))
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
var AppConfig = types.AppConfig{}
|
var AppConfig = types.AppConfig{}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- *
|
/* ---------------------------------------------------------------- *
|
||||||
* METHODS
|
* METHODS getters
|
||||||
* ---------------------------------------------------------------- */
|
* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
// Extrahiert Inhalte einer YAML Config und parset dies als Struktur
|
// Extrahiert Inhalte einer YAML Config und parset dies als Struktur
|
||||||
@ -38,3 +38,19 @@ func AppConfigShowMetrics() bool {
|
|||||||
func AppConfigPerformChecks() bool {
|
func AppConfigPerformChecks() bool {
|
||||||
return AppConfig.Options.Checks
|
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
|
||||||
|
}
|
||||||
|
@ -38,6 +38,10 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
var arguments *types.CliArguments
|
var arguments *types.CliArguments
|
||||||
|
var (
|
||||||
|
cmdMissing bool
|
||||||
|
showChecks bool
|
||||||
|
)
|
||||||
|
|
||||||
// assets festlegen
|
// assets festlegen
|
||||||
setup.Res = res
|
setup.Res = res
|
||||||
@ -45,9 +49,10 @@ func main() {
|
|||||||
|
|
||||||
// cli arguments parsen
|
// cli arguments parsen
|
||||||
arguments, err = cli.ParseCli(os.Args)
|
arguments, err = cli.ParseCli(os.Args)
|
||||||
cmdMissing := cli.ParseCliCommandMissing(err)
|
cmdMissing = cli.ParseCliCommandMissing(err)
|
||||||
|
|
||||||
// initialisiere basic optionen wie Logging
|
// initialisiere basic optionen wie Logging
|
||||||
|
showChecks = false
|
||||||
if err == nil {
|
if err == nil {
|
||||||
quiet := arguments.QuietModeOn()
|
quiet := arguments.QuietModeOn()
|
||||||
if arguments.InteractiveMode() {
|
if arguments.InteractiveMode() {
|
||||||
@ -56,16 +61,12 @@ func main() {
|
|||||||
logging.SetQuietMode(quiet)
|
logging.SetQuietMode(quiet)
|
||||||
logging.SetDebugMode(arguments.DebugModeOn())
|
logging.SetDebugMode(arguments.DebugModeOn())
|
||||||
logging.SetAnsiMode(arguments.ShowColour())
|
logging.SetAnsiMode(arguments.ShowColour())
|
||||||
|
showChecks = arguments.ShowChecks()
|
||||||
}
|
}
|
||||||
|
|
||||||
// app config (intern) intialisieren
|
// app config (intern) intialisieren
|
||||||
if err == nil {
|
|
||||||
err = setup.AppConfigInitialise()
|
err = setup.AppConfigInitialise()
|
||||||
}
|
setup.SetAppConfigPerformChecks(showChecks)
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
setup.AppConfig.Options.Checks = arguments.ShowChecks()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if arguments.ModeVersion.Happened() {
|
if arguments.ModeVersion.Happened() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user