github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/cmd/commands/version.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package commands 5 6 import ( 7 "github.com/mattermost/mattermost-server/app" 8 "github.com/mattermost/mattermost-server/cmd" 9 "github.com/mattermost/mattermost-server/model" 10 "github.com/mattermost/mattermost-server/store" 11 "github.com/mattermost/mattermost-server/store/sqlstore" 12 "github.com/spf13/cobra" 13 ) 14 15 var VersionCmd = &cobra.Command{ 16 Use: "version", 17 Short: "Display version information", 18 RunE: versionCmdF, 19 } 20 21 func init() { 22 cmd.RootCmd.AddCommand(VersionCmd) 23 } 24 25 func versionCmdF(command *cobra.Command, args []string) error { 26 a, err := cmd.InitDBCommandContextCobra(command) 27 if err != nil { 28 return err 29 } 30 31 printVersion(a) 32 33 return nil 34 } 35 36 func printVersion(a *app.App) { 37 cmd.CommandPrintln("Version: " + model.CurrentVersion) 38 cmd.CommandPrintln("Build Number: " + model.BuildNumber) 39 cmd.CommandPrintln("Build Date: " + model.BuildDate) 40 cmd.CommandPrintln("Build Hash: " + model.BuildHash) 41 cmd.CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady) 42 if supplier, ok := a.Srv.Store.(*store.LayeredStore).DatabaseLayer.(*sqlstore.SqlSupplier); ok { 43 cmd.CommandPrintln("DB Version: " + supplier.GetCurrentSchemaVersion()) 44 } 45 }