diff --git a/Makefile b/Makefile index de02bb3..c0807a0 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ GOFMT ?= gofmt -s GOFLAGS := -v -mod=vendor EXTRA_GOFLAGS ?= -LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" -X "main.Tags=$(TAGS)" +LDFLAGS := -X "cmd.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')" -X "main.Tags=$(TAGS)" PACKAGES ?= $(filter-out git.kolaente.de/sofaraum/client/integrations,$(shell go list ./... | grep -v /vendor/)) SOURCES ?= $(shell find . -name "*.go" -type f) diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..2a61b42 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,60 @@ +// Sofaraum client is the client software which collects statistics about +// wifi devices nearby and then sends them to the Sofaraum Server. +// Copyright (c) 2018. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" +) + +// Version sets the version. Will be overwritten by drone or when building with the makefile +var Version = "0.1" + +var TheSofa = ` + ___.--------'´´´´´´:´´´´´´'--------.___ + ( | : | ) + \ ,;,,, : | / + |\%%%%\___________:__________/~~~~~/| + / ,\%%%%\ | / @*@ /, \ + /_ / ´´´´´ | ~~~~~~ \ _\ + (@l) | (@l) + ||__________________|__________________|| + ||_____________________________________|| + /_|_____________________________________|_\ + + ================================================= + Sofaraum Client Version ` + Version + ` + + Copyright (C) 2018 K. Langenberg + This program comes with ABSOLUTELY NO WARRANTY + This is free software, and you are welcome + to redistribute it under certain conditions + =================================================` + +// versionCmd represents the version command +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Shows version information", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(TheSofa) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +} diff --git a/main.go b/main.go index b29f170..00cbfa2 100644 --- a/main.go +++ b/main.go @@ -21,30 +21,6 @@ import ( "git.kolaente.de/sofaraum/client/cmd" ) -// Version sets the version. Will be overwritten by drone or when building with the makefile -const Version = `0.1` - -const TheSofa = ` - ___.--------'´´´´´´:´´´´´´'--------.___ - ( | : | ) - \ ,;,,, : | / - |\%%%%\___________:__________/~~~~~/| - / ,\%%%%\ | / @*@ /, \ - /_ / ´´´´´ | ~~~~~~ \ _\ - (@l) | (@l) - ||__________________|__________________|| - ||_____________________________________|| - /_|_____________________________________|_\ - - ================================================= - Sofaraum Client Version ` + Version + ` - - Copyright (C) 2018 K. Langenberg - This program comes with ABSOLUTELY NO WARRANTY - This is free software, and you are welcome - to redistribute it under certain conditions - =================================================` - func main() { cmd.Execute() }