From 98b7f52e441f4c57b876381b2d0260fcc6a7dbe8 Mon Sep 17 00:00:00 2001 From: Andreas Ulm Date: Sun, 28 Apr 2019 22:37:13 +0200 Subject: [PATCH] added version command Signed-off-by: Andreas Ulm --- cmd/version.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cmd/version.go diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..e9f8813 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,35 @@ +// Copyright © 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package cmd + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" +) + +// Version holds the current Gitea version +var Version = "0.1.0-dev" + +// Tags holds the build tags used +var Tags = "" + +// versionCmd represents the version command +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print version", + Long: ``, + Run: func(cmd *cobra.Command, args []string) { + if len(Tags) > 0 { + Version += " built with: " + strings.Replace(Tags, " ", ", ", -1) + } + fmt.Println("Version " + Version) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +}