github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/app/whatsnew/whatsnew.go (about) 1 package whatsnew 2 3 import ( 4 "bytes" 5 "fmt" 6 "io" 7 "os" 8 9 "github.com/lmorg/murex/app" 10 "github.com/lmorg/murex/config/profile" 11 ) 12 13 func Display() { 14 var ( 15 version string 16 b []byte 17 ) 18 19 f, err := os.OpenFile(profile.ModulePath()+"/version", os.O_CREATE|os.O_RDONLY, 0644) 20 if err != nil { 21 goto changelog 22 } 23 24 b, err = io.ReadAll(f) 25 f.Close() 26 if err != nil { 27 goto changelog 28 } 29 30 version = string(bytes.TrimSpace(b)) 31 32 if version == app.Version() { 33 return 34 } 35 36 changelog: 37 fmt.Fprintf(os.Stdout, "Welcome to murex %d.%d.%d\nChangelog: https://murex.rocks/CHANGELOG.html\nOr run `help changelog/v%d.%d` from the command line\n", 38 app.Major, app.Minor, app.Revision, app.Major, app.Minor) 39 40 f, err = os.OpenFile(profile.ModulePath()+"/version", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) 41 if err != nil { 42 return 43 } 44 f.WriteString(app.Version()) 45 f.Close() 46 }