github.com/mattermosttest/mattermost-server/v5@v5.0.0-20200917143240-9dfa12e121f9/cmd/mattermost/commands/version.go (about)

     1  // Copyright (c) 2015-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/v5/app"
     8  	"github.com/mattermost/mattermost-server/v5/model"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  var VersionCmd = &cobra.Command{
    13  	Use:   "version",
    14  	Short: "Display version information",
    15  	RunE:  versionCmdF,
    16  }
    17  
    18  func init() {
    19  	RootCmd.AddCommand(VersionCmd)
    20  }
    21  
    22  func versionCmdF(command *cobra.Command, args []string) error {
    23  	a, err := InitDBCommandContextCobra(command)
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	printVersion(a)
    29  
    30  	return nil
    31  }
    32  
    33  func printVersion(a *app.App) {
    34  	CommandPrintln("Version: " + model.CurrentVersion)
    35  	CommandPrintln("Build Number: " + model.BuildNumber)
    36  	CommandPrintln("Build Date: " + model.BuildDate)
    37  	CommandPrintln("Build Hash: " + model.BuildHash)
    38  	CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady)
    39  	CommandPrintln("DB Version: " + a.Srv().Store.GetCurrentSchemaVersion())
    40  }