add simulated flag

This commit is contained in:
bui 2021-10-08 14:44:36 +02:00 committed by alteredCoder
parent 64123b7249
commit 8994e57bdc

View file

@ -115,12 +115,7 @@ Enable given information push to the central API. Allows to empower the console`
DisableAutoGenTag: true, DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if enableAll { if enableAll {
csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = types.BoolPtr(true) SetConsoleOpts(csconfig.CONSOLE_CONFIGS, true)
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(true)
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(true)
csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(true)
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(true)
} else { } else {
SetConsoleOpts(args, true) SetConsoleOpts(args, true)
} }
@ -144,12 +139,7 @@ Disable given information push to the central API.`,
DisableAutoGenTag: true, DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if disableAll { if disableAll {
csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = types.BoolPtr(false) SetConsoleOpts(csconfig.CONSOLE_CONFIGS, false)
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(false)
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(false)
csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(false)
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(false)
} else { } else {
SetConsoleOpts(args, false) SetConsoleOpts(args, false)
} }
@ -205,55 +195,65 @@ func SetConsoleOpts(args []string, wanted bool) {
/*for each flag check if it's already set before setting it*/ /*for each flag check if it's already set before setting it*/
if csConfig.API.Server.ConsoleConfig.ShareCustomScenarios != nil { if csConfig.API.Server.ConsoleConfig.ShareCustomScenarios != nil {
if *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios == wanted { if *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios == wanted {
log.Infof("%s already set to %t", wanted) log.Infof("%s already set to %t", csconfig.SEND_CUSTOM_SCENARIOS, wanted)
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_CUSTOM_SCENARIOS, wanted)
*csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = wanted *csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = wanted
} }
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_CUSTOM_SCENARIOS, wanted)
csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = types.BoolPtr(wanted) csConfig.API.Server.ConsoleConfig.ShareCustomScenarios = types.BoolPtr(wanted)
} }
case csconfig.SEND_TAINTED_SCENARIOS: case csconfig.SEND_TAINTED_SCENARIOS:
/*for each flag check if it's already set before setting it*/ /*for each flag check if it's already set before setting it*/
if csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios != nil { if csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios != nil {
if *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios == wanted { if *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios == wanted {
log.Infof("%s already set to %t", wanted) log.Infof("%s already set to %t", csconfig.SEND_TAINTED_SCENARIOS, wanted)
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_TAINTED_SCENARIOS, wanted)
*csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = wanted *csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = wanted
} }
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_TAINTED_SCENARIOS, wanted)
csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(wanted) csConfig.API.Server.ConsoleConfig.ShareTaintedScenarios = types.BoolPtr(wanted)
} }
case csconfig.SEND_MANUAL_SCENARIOS: case csconfig.SEND_MANUAL_SCENARIOS:
/*for each flag check if it's already set before setting it*/ /*for each flag check if it's already set before setting it*/
if csConfig.API.Server.ConsoleConfig.ShareManualDecisions != nil { if csConfig.API.Server.ConsoleConfig.ShareManualDecisions != nil {
if *csConfig.API.Server.ConsoleConfig.ShareManualDecisions == wanted { if *csConfig.API.Server.ConsoleConfig.ShareManualDecisions == wanted {
log.Infof("%s already set to %t", wanted) log.Infof("%s already set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
*csConfig.API.Server.ConsoleConfig.ShareManualDecisions = wanted *csConfig.API.Server.ConsoleConfig.ShareManualDecisions = wanted
} }
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(wanted) csConfig.API.Server.ConsoleConfig.ShareManualDecisions = types.BoolPtr(wanted)
} }
case csconfig.SEND_LIVE_DECISIONS: case csconfig.SEND_LIVE_DECISIONS:
/*for each flag check if it's already set before setting it*/ /*for each flag check if it's already set before setting it*/
if csConfig.API.Server.ConsoleConfig.ShareDecisions != nil { if csConfig.API.Server.ConsoleConfig.ShareDecisions != nil {
if *csConfig.API.Server.ConsoleConfig.ShareDecisions == wanted { if *csConfig.API.Server.ConsoleConfig.ShareDecisions == wanted {
log.Infof("%s already set to %t", wanted) log.Infof("%s already set to %t", csconfig.SEND_LIVE_DECISIONS, wanted)
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_LIVE_DECISIONS, wanted)
*csConfig.API.Server.ConsoleConfig.ShareDecisions = wanted *csConfig.API.Server.ConsoleConfig.ShareDecisions = wanted
} }
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_LIVE_DECISIONS, wanted)
csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(wanted) csConfig.API.Server.ConsoleConfig.ShareDecisions = types.BoolPtr(wanted)
} }
case csconfig.SEND_SIMULATED_DECISIONS: case csconfig.SEND_SIMULATED_DECISIONS:
/*for each flag check if it's already set before setting it*/ /*for each flag check if it's already set before setting it*/
if csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions != nil { if csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions != nil {
if *csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions == wanted { if *csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions == wanted {
log.Infof("%s already set to %t", wanted) log.Infof("%s already set to %t", csconfig.SEND_SIMULATED_DECISIONS, wanted)
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_SIMULATED_DECISIONS, wanted)
*csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = wanted *csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = wanted
} }
} else { } else {
log.Infof("%s set to %t", csconfig.SEND_SIMULATED_DECISIONS, wanted)
csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(wanted) csConfig.API.Server.ConsoleConfig.ShareSimulatedDecisions = types.BoolPtr(wanted)
} }
default: default: