aboutsummaryrefslogtreecommitdiffstats
path: root/aerc.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-08-12 12:24:52 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-22 15:46:33 +0200
commitd7e6dc3649eadc27bdfdac77785b6bbf77d30b79 (patch)
treefcd3eebf66f7ac3264b06dc584f0c5c09f716028 /aerc.go
parent45e506e6aebdfdcb743d2d861eaddb85a01b3d5b (diff)
downloadaerc-d7e6dc3649eadc27bdfdac77785b6bbf77d30b79.tar.gz
aerc: add build info to version string
Example: $ aerc -v aerc 0.11.0 +notmuch (go1.18.4 amd64 linux) Also include that version information in the debug and panic logs. debug.ReadBuildInfo() is only available in go 1.18+. Add a new variable set at build time to store $GOFLAGS. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'aerc.go')
-rw-r--r--aerc.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/aerc.go b/aerc.go
index 6e6c1d14..804befd2 100644
--- a/aerc.go
+++ b/aerc.go
@@ -5,7 +5,9 @@ import (
"errors"
"fmt"
"os"
+ "runtime"
"sort"
+ "strings"
"time"
"git.sr.ht/~sircmpwn/getopt"
@@ -89,6 +91,17 @@ func getCompletions(aerc *widgets.Aerc, cmd string) []string {
// set at build time
var Version string
+var Flags string
+
+func buildInfo() string {
+ info := Version
+ if strings.Contains(Flags, "notmuch") {
+ info += " +notmuch"
+ }
+ info += fmt.Sprintf(" (%s %s %s)",
+ runtime.Version(), runtime.GOARCH, runtime.GOOS)
+ return info
+}
func usage(msg string) {
fmt.Fprintln(os.Stderr, msg)
@@ -124,9 +137,10 @@ func main() {
usage("error: " + err.Error())
return
}
+ logging.BuildInfo = buildInfo()
for _, opt := range opts {
if opt.Option == 'v' {
- fmt.Println("aerc " + Version)
+ fmt.Println("aerc " + logging.BuildInfo)
return
}
}
@@ -149,7 +163,7 @@ func main() {
if !isatty.IsTerminal(os.Stdout.Fd()) {
logging.Init()
}
- logging.Infof("Starting up")
+ logging.Infof("Starting up version %s", logging.BuildInfo)
conf, err := config.LoadConfigFromFile(nil)
if err != nil {