@@ -7,14 +7,13 @@ import (
77 "log/slog"
88 "os"
99 "path/filepath"
10- "runtime/debug"
1110 "sort"
12- "strings"
1311
1412 "github.com/spf13/cobra"
1513
1614 mcpserver "github.com/mark3labs/mcp-go/server"
1715
16+ "github.com/boringsql/dryrun/internal/buildinfo"
1817 "github.com/boringsql/dryrun/internal/config"
1918 "github.com/boringsql/dryrun/internal/diff"
2019 "github.com/boringsql/dryrun/internal/history"
@@ -23,22 +22,6 @@ import (
2322 "github.com/boringsql/dryrun/internal/schema"
2423)
2524
26- // version is set via ldflags: -X main.version=v0.1.0
27- var version string
28-
29- func getVersion () string {
30- if version != "" {
31- return version
32- }
33- if info , ok := debug .ReadBuildInfo (); ok {
34- v := info .Main .Version
35- if v != "" && v != "(devel)" && ! strings .Contains (v , "0.0.0-" ) {
36- return v
37- }
38- }
39- return "dev"
40- }
41-
4225var (
4326 flagDB string
4427 flagProfile string
@@ -50,7 +33,7 @@ func main() {
5033 root := & cobra.Command {
5134 Use : "dryrun" ,
5235 Short : "PostgreSQL schema intelligence" ,
53- Version : getVersion (),
36+ Version : buildinfo . Get (),
5437 }
5538
5639 pf := root .PersistentFlags ()
@@ -62,14 +45,26 @@ func main() {
6245 root .AddCommand (
6346 probeCmd (), initCmd (), importCmd (), dumpSchemaCmd (),
6447 lintCmd (), driftCmd (), snapshotCmd (), profileCmd (),
65- mcpServeCmd (), statsCmd (),
48+ mcpServeCmd (), statsCmd (), versionCmd (),
6649 )
6750
6851 if err := root .Execute (); err != nil {
6952 os .Exit (1 )
7053 }
7154}
7255
56+ func versionCmd () * cobra.Command {
57+ return & cobra.Command {
58+ Use : "version" ,
59+ Short : "Print dryrun and history schema versions" ,
60+ RunE : func (cmd * cobra.Command , args []string ) error {
61+ fmt .Printf ("dryrun %s\n " , buildinfo .Get ())
62+ fmt .Printf ("history schema: v%d\n " , history .HistorySchemaVersion )
63+ return nil
64+ },
65+ }
66+ }
67+
7368func probeCmd () * cobra.Command {
7469 return & cobra.Command {
7570 Use : "probe" ,
@@ -893,7 +888,7 @@ func mcpServeCmd() *cobra.Command {
893888 server .SetUninitialized (candidates )
894889 }
895890
896- mcpSrv := mcpserver .NewMCPServer ("dryrun" , getVersion (),
891+ mcpSrv := mcpserver .NewMCPServer ("dryrun" , buildinfo . Get (),
897892 mcpserver .WithInstructions (server .Instructions ()),
898893 )
899894 server .Register (mcpSrv )
0 commit comments