master > master: code go - fügte settings hinzu

This commit is contained in:
RD
2021-11-03 18:43:13 +01:00
parent f55677ed8b
commit f7ef295ec8
11 changed files with 208 additions and 66 deletions

View File

@@ -6,6 +6,7 @@ package menus
import (
"fmt"
"strings"
"ads/internal/core/logging"
"ads/internal/core/utils"
@@ -16,7 +17,7 @@ import (
* ---------------------------------------------------------------- */
// Zeigt Prompt mit Liste von Optionen an
func PromptListOfOptions(messages []string, options [][2]string, breaks []int, defaultChoice string) (string, bool) {
func promptListOfOptions(messages []string, options [][2]string, breaks []int, defaultChoice string) (string, bool) {
var n = len(options)
var (
choice string
@@ -32,6 +33,8 @@ func PromptListOfOptions(messages []string, options [][2]string, breaks []int, d
lines = append(lines, message)
}
lines = append(lines, "")
textbar := fmt.Sprintf(" \033[93m+%s+\033[0m", strings.Repeat("-", 40))
lines = append(lines, textbar)
for i, obj := range options {
key := obj[0]
label := obj[1]
@@ -42,13 +45,14 @@ func PromptListOfOptions(messages []string, options [][2]string, breaks []int, d
lines = append(lines, fmt.Sprintf(" \033[93;1m%v)\033[0m %v", key, label))
}
if i < n-1 && utils.ArrayContains(breaks, i) {
lines = append(lines, " \033[93m--------\033[0m")
lines = append(lines, " \033[93m+----\033[0m")
}
i++
}
if !(defaultChoice == "" || defaultChoice == "-1") {
lines = append(lines, textbar)
if !(defaultChoice == "") {
lines = append(lines, "")
lines = append(lines, "\033[91;2m*\033[0m\033[2m = Default\033[0m")
lines = append(lines, " \033[91;2m*\033[0m\033[2m = Default\033[0m")
}
// Wiederhole Prompt, bis gültige Eingabe erreicht