task: add the task selection skeleton
This commit is contained in:
parent
423c0b5a37
commit
d50bf24226
18
go/main.go
18
go/main.go
@ -5,6 +5,7 @@ import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks"
|
||||
"ocl/portainer-devtool/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -36,8 +37,23 @@ func main() {
|
||||
// 5. Quit`)
|
||||
}
|
||||
|
||||
utils.PromptMenu(printMainMenu)
|
||||
option := utils.SelectMenuItem(printMainMenu)
|
||||
|
||||
index, err := strconv.Atoi(option)
|
||||
if err != nil {
|
||||
log.Printf("please type the option number\n")
|
||||
continue
|
||||
}
|
||||
|
||||
if index < 1 || index > len(taskItems) {
|
||||
log.Printf("no such option %s, please select again\n", option)
|
||||
continue
|
||||
}
|
||||
|
||||
err = taskItems[index-1].Execute()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func PromptConfirm(question string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func PromptMenu(listMenu func()) string {
|
||||
func SelectMenuItem(listMenu func()) string {
|
||||
listMenu()
|
||||
|
||||
var option string
|
||||
|
Loading…
Reference in New Issue
Block a user