From 2b309fbda710146c6edd04050acd901dc4805b28 Mon Sep 17 00:00:00 2001 From: mappu Date: Fri, 28 Jun 2024 11:21:14 +1200 Subject: [PATCH] gui: add help option to show driver versions --- main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/main.go b/main.go index 31babbc..e9f222c 100644 --- a/main.go +++ b/main.go @@ -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