From 11cbb597471127c1b29e78e6cad0a1a4d93ea24c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 17 May 2018 12:40:40 -0700 Subject: Renaming platform binary to mattermost. (#8801) --- cmd/mattermost/commands/version.go | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cmd/mattermost/commands/version.go (limited to 'cmd/mattermost/commands/version.go') diff --git a/cmd/mattermost/commands/version.go b/cmd/mattermost/commands/version.go new file mode 100644 index 000000000..e26d5e09c --- /dev/null +++ b/cmd/mattermost/commands/version.go @@ -0,0 +1,44 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package commands + +import ( + "github.com/mattermost/mattermost-server/app" + "github.com/mattermost/mattermost-server/model" + "github.com/mattermost/mattermost-server/store" + "github.com/mattermost/mattermost-server/store/sqlstore" + "github.com/spf13/cobra" +) + +var VersionCmd = &cobra.Command{ + Use: "version", + Short: "Display version information", + RunE: versionCmdF, +} + +func init() { + RootCmd.AddCommand(VersionCmd) +} + +func versionCmdF(command *cobra.Command, args []string) error { + a, err := InitDBCommandContextCobra(command) + if err != nil { + return err + } + + printVersion(a) + + return nil +} + +func printVersion(a *app.App) { + CommandPrintln("Version: " + model.CurrentVersion) + CommandPrintln("Build Number: " + model.BuildNumber) + CommandPrintln("Build Date: " + model.BuildDate) + CommandPrintln("Build Hash: " + model.BuildHash) + CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady) + if supplier, ok := a.Srv.Store.(*store.LayeredStore).DatabaseLayer.(*sqlstore.SqlSupplier); ok { + CommandPrintln("DB Version: " + supplier.GetCurrentSchemaVersion()) + } +} -- cgit v1.2.3-1-g7c22