tuimenu/examples/test/main.go

42 lines
1.1 KiB
Go
Raw Normal View History

2024-10-16 22:08:50 +02:00
package main
import (
"fmt"
2024-10-19 09:06:14 +02:00
"log"
"time"
2024-10-16 22:08:50 +02:00
"git.qowevisa.me/Qowevisa/tuimenu/simple"
)
func main() {
m := simple.CreateMenu(
simple.WithCustomTitle("My Custom Title"),
2024-10-19 09:06:14 +02:00
simple.WithUsageOfEscapeCodes(),
2024-10-16 22:08:50 +02:00
)
2024-10-19 09:06:14 +02:00
// Using this function will redirect every log.PrintX func in THIS file
// to m.Log buffer that will Flush everything at the start of next iteration
m.RedirectLogOutputToBufferedLogger()
2024-10-16 22:08:50 +02:00
nameName, err := m.AddCommand("0", "NameName", func(m *simple.Menu) error {
2024-10-19 09:06:14 +02:00
log.Printf("hello, world\n")
time.Sleep(time.Second * 3)
m.Log.Logf("some data = %d\n", 42)
time.Sleep(time.Second * 1)
m.Log.Logf("some data = %d\n", 43)
time.Sleep(time.Second * 1)
m.Log.Logf("some data = %d\n", 44)
log.Printf("asdas")
time.Sleep(time.Second * 1)
2024-10-16 22:08:50 +02:00
return nil
})
if err != nil {
panic(err)
}
gr := nameName.AddGroupingCommand("gr1", "Some grouping")
gr.AddExecCommand("some1", "Some func that does funny stuff", func(m *simple.Menu) error {
fmt.Printf("Some funcy stuff\n")
return nil
})
m.AddCommand("lalalla", "something", simple.EmptyAction)
m.Start()
}