gui: add help option to show driver versions

This commit is contained in:
mappu 2024-06-28 11:21:14 +12:00
parent 70db402cdf
commit 2b309fbda7

31
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"runtime/debug"
"strings"
"unsafe"
@ -118,6 +119,11 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
mnuHelp := vcl.NewMenuItem(f)
mnuHelp.SetCaption("Help")
mnuHelpVersion := vcl.NewMenuItem(mnuHelp)
mnuHelpVersion.SetCaption("Driver versions...")
mnuHelpVersion.SetOnClick(f.OnMenuHelpVersion)
mnuHelp.Add(mnuHelpVersion)
mnuHelpHomepage := vcl.NewMenuItem(mnuHelp)
mnuHelpHomepage.SetCaption("About yvbolt")
mnuHelpHomepage.SetShortCutFromString("F1")
@ -319,6 +325,31 @@ func (f *TMainForm) OnMnuHelpHomepage(sender vcl.IObject) {
}
}
func (f *TMainForm) OnMenuHelpVersion(sender vcl.IObject) {
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
info := "This version of yvbolt was compiled with:\n"
for _, dep := range bi.Deps {
// Filter to only interesting things
switch dep.Path {
case `github.com/cockroachdb/pebble`,
`github.com/dgraph-io/badger/v4`,
`github.com/mattn/go-sqlite3`,
`github.com/redis/go-redis/v9`,
`go.etcd.io/bbolt`,
`modernc.org/sqlite`:
info += fmt.Sprintf("- %s %s\n", dep.Path, dep.Version)
}
}
vcl.ShowMessage(info)
}
func (f *TMainForm) OnNavContextPopup(sender vcl.IObject, mousePos types.TPoint, handled *bool) {
*handled = true