summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2020-10-15 20:02:19 -0700
committerStan Hu <stanhu@gmail.com>2020-10-15 22:41:48 -0700
commit9010cdccde441d37aff8a1d76f2e701134e42801 (patch)
treee9184718e6ad55b85dc805ea4359d4f0e4465daa /cmd
parent890bda90c9a09aa8d5a2441974138b92c8e38c18 (diff)
downloadgitlab-shell-9010cdccde441d37aff8a1d76f2e701134e42801.tar.gz
Add support for -version argument
This will help determine the version of the binary particularly on Cloud Native GitLab, where VERSION may not be shipped with the binaries.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitlab-shell/main.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/gitlab-shell/main.go b/cmd/gitlab-shell/main.go
index 763aa5e..ff3a354 100644
--- a/cmd/gitlab-shell/main.go
+++ b/cmd/gitlab-shell/main.go
@@ -12,7 +12,21 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
)
+var (
+ // Version is the current version of gitlab-shell
+ Version = "(unknown version)" // Set at build time in the Makefile
+ // BuildTime signifies the time the binary was build
+ BuildTime = "19700101.000000" // Set at build time in the Makefile
+)
+
func main() {
+ // We can't use the flag library because gitlab-shell receives other arguments
+ // that confuse the parser.
+ if len(os.Args) == 2 && os.Args[1] == "-version" {
+ fmt.Printf("gitlab-shell %s-%s\n", Version, BuildTime)
+ os.Exit(0)
+ }
+
readWriter := &readwriter.ReadWriter{
Out: os.Stdout,
In: os.Stdin,