utils: refactor PrintMenu with tasker array
This commit is contained in:
parent
a115970e7e
commit
9c56ec0d85
@ -1,6 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"ocl/portainer-devtool/tasks"
|
||||
)
|
||||
|
||||
const (
|
||||
colorReset string = "\033[0m"
|
||||
@ -41,6 +44,20 @@ func InputPrint(message string) {
|
||||
fmt.Println(colorYellow, message, colorReset)
|
||||
}
|
||||
|
||||
func PrintMenu(question string, tasks []tasks.Tasker) {
|
||||
if question != "" {
|
||||
InputPrint(fmt.Sprintf("[%s]", question))
|
||||
}
|
||||
|
||||
menuContent := ""
|
||||
|
||||
for i, task := range tasks {
|
||||
menuContent += fmt.Sprintf("%d. %s\n", i+1, task.String())
|
||||
}
|
||||
|
||||
fmt.Println(colorCyan, menuContent, colorReset)
|
||||
}
|
||||
|
||||
func MenuPrint(question, menu string) {
|
||||
if question != "" {
|
||||
InputPrint(fmt.Sprintf("[%s]", question))
|
||||
|
Loading…
Reference in New Issue
Block a user