From 5d69a98a025620e5c94bf08cb64957f1690f2a1b Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Fri, 9 Feb 2024 15:19:11 +0800 Subject: [PATCH] feat: add version --- server/daemon/server/server.go | 3 ++- server/go.mod | 1 + server/go.sum | 4 ++-- server/main.go | 6 ++++-- server/release/release.go | 11 +++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 server/release/release.go diff --git a/server/daemon/server/server.go b/server/daemon/server/server.go index 676da26..b41458e 100644 --- a/server/daemon/server/server.go +++ b/server/daemon/server/server.go @@ -16,6 +16,7 @@ import ( "github.com/nedpals/bugbuddy/server/daemon/types" "github.com/nedpals/bugbuddy/server/helpers" "github.com/nedpals/bugbuddy/server/logger" + "github.com/nedpals/bugbuddy/server/release" "github.com/nedpals/bugbuddy/server/rpc" "github.com/nedpals/errgoengine" "github.com/nedpals/errgoengine/error_templates" @@ -129,7 +130,7 @@ func (d *Server) Handle(ctx context.Context, c *jsonrpc2.Conn, r *jsonrpc2.Reque // introduce the server to the client c.Reply(ctx, r.ID, &types.ServerInfo{ Success: true, - Version: "0.1.0", + Version: release.Version(), ProcessID: info.ProcessId, SupportedFileExtensions: engineSupportedExtensions, }) diff --git a/server/go.mod b/server/go.mod index 79bb5aa..b152d0b 100644 --- a/server/go.mod +++ b/server/go.mod @@ -34,6 +34,7 @@ require ( ) require ( + github.com/carlmjohnson/versioninfo v0.22.5 github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/lucasepe/codename v0.2.0 github.com/segmentio/asm v1.2.0 // indirect diff --git a/server/go.sum b/server/go.sum index 2afabff..1d729c5 100644 --- a/server/go.sum +++ b/server/go.sum @@ -1,3 +1,5 @@ +github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc= +github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -25,8 +27,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/nedpals/errgoengine v0.0.0-20240202043608-58fd022a3bc4 h1:PAlxtCGnxixq6THwDkjlPd2/ExbfgVpL9UnUBh42qKw= -github.com/nedpals/errgoengine v0.0.0-20240202043608-58fd022a3bc4/go.mod h1:uYC7Mfw/No0v7VerEzJMPt6MdqgS6OYlkWdhan7cnz0= github.com/nedpals/errgoengine v0.0.0-20240204172620-f4253b2cd98c h1:MofuPKky/AzH2n5asPmo+ybZB3izFwo2ZVt467QlCRQ= github.com/nedpals/errgoengine v0.0.0-20240204172620-f4253b2cd98c/go.mod h1:uYC7Mfw/No0v7VerEzJMPt6MdqgS6OYlkWdhan7cnz0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/server/main.go b/server/main.go index 834d46a..02f29e5 100644 --- a/server/main.go +++ b/server/main.go @@ -13,13 +13,15 @@ import ( "github.com/nedpals/bugbuddy/server/executor" "github.com/nedpals/bugbuddy/server/helpers" "github.com/nedpals/bugbuddy/server/lsp_server" + "github.com/nedpals/bugbuddy/server/release" "github.com/nedpals/errgoengine" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ - Use: "bugbuddy", - Short: "BugBuddy is a runtime error analyzer and assistant.", + Use: "bugbuddy", + Version: release.Version(), + Short: "BugBuddy is a runtime error analyzer and assistant.", PersistentPreRun: func(cmd *cobra.Command, args []string) { port, err := cmd.Flags().GetInt("port") if err != nil { diff --git a/server/release/release.go b/server/release/release.go new file mode 100644 index 0000000..5e14791 --- /dev/null +++ b/server/release/release.go @@ -0,0 +1,11 @@ +package release + +import ( + "fmt" + + "github.com/carlmjohnson/versioninfo" +) + +func Version() string { + return fmt.Sprintf("%s %s", versioninfo.Short(), versioninfo.Version) +}