diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2693959..e057e63 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -14,7 +14,7 @@ builds: - windows - darwin ldflags: - - -s -w -X 'github.com/richardwooding/powerdown/version/Version={{.Version}}' -X 'github.com/richardwooding/powerdown/version/CommitHash={{.Commit}}' -X github.com/richardwooding/powerdown/version/BuildTimestamp={{.Date}}' + - "-s -w -X 'github.com/richardwooding/powerdown/version/Version={{.Version}}' -X 'github.com/richardwooding/powerdown/version/CommitHash={{.Commit}}' -X github.com/richardwooding/powerdown/version/BuildTimestamp={{.Date}}'" archives: - replacements: darwin: Darwin diff --git a/cmd/root.go b/cmd/root.go index aa5cfd0..d13ab77 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -25,7 +25,6 @@ import ( "fmt" "github.com/fatih/color" "github.com/richardwooding/powerdown/api" - "github.com/richardwooding/powerdown/version" "github.com/rodaine/table" "log" "os" @@ -85,8 +84,6 @@ func init() { // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") headerFmt = color.New(color.FgGreen, color.Underline).SprintfFunc() columnFmt = color.New(color.FgYellow).SprintfFunc() - - println("Powerdown " + version.BuildVersion()) } // initConfig reads in config file and ENV variables if set. diff --git a/go.mod b/go.mod index e60543c..5f54df4 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/fatih/color v1.13.0 + github.com/icza/bitio v1.1.0 github.com/rodaine/table v1.0.1 github.com/spf13/cobra v1.5.0 github.com/spf13/viper v1.12.0 diff --git a/go.sum b/go.sum index 42b60ca..ffa4622 100644 --- a/go.sum +++ b/go.sum @@ -125,6 +125,10 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/icza/bitio v1.1.0 h1:ysX4vtldjdi3Ygai5m1cWy4oLkhWTAi+SyO6HC8L9T0= +github.com/icza/bitio v1.1.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A= +github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k= +github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= diff --git a/main.go b/main.go index b60e90d..343e6d6 100644 --- a/main.go +++ b/main.go @@ -21,18 +21,13 @@ THE SOFTWARE. */ package main -import "github.com/richardwooding/powerdown/cmd" - -var ( - version = "dev" - commit = "" - date = "" +import ( + "github.com/richardwooding/powerdown/cmd" + "github.com/richardwooding/powerdown/version" ) -func GetVersionString() string { - return version -} - func main() { + println("Powerdown " + version.Version) + println() cmd.Execute() } diff --git a/model/area.go b/model/area.go index d6371ee..7174ca4 100644 --- a/model/area.go +++ b/model/area.go @@ -1,3 +1,24 @@ +/* +Copyright © 2022 Richard Wooding richard.wooding@gmail.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ package model import "time" diff --git a/model/nearby.go b/model/nearby.go index e550f56..a5f8c17 100644 --- a/model/nearby.go +++ b/model/nearby.go @@ -1,3 +1,24 @@ +/* +Copyright © 2022 Richard Wooding richard.wooding@gmail.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ package model type NearbyResponse struct { diff --git a/version/Version.go b/version/Version.go index f21fa6a..c02ec3d 100644 --- a/version/Version.go +++ b/version/Version.go @@ -1,13 +1,58 @@ +/* +Copyright © 2022 Richard Wooding richard.wooding@gmail.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ package version -import "fmt" +import ( + "fmt" + "runtime/debug" + "github.com/icza/bitio" +) + var ( - Version = "dev" + Version = "devel" CommitHash = "" BuildTimestamp = "" ) +func init() { + if Version == "devel" { + _ = bitio.NewReader + bi, ok := debug.ReadBuildInfo() + if !ok { + return + } + for _, dep := range bi.Deps { + if dep.Path == "github.com/richardwooding/powerdown" { + Version = dep.Version + } + } + } +} + +func BuildSimpleVersion() string { + return fmt.Sprintf("%s", Version) +} + func BuildVersion() string { return fmt.Sprintf("%s-%s (%s)", Version, CommitHash, BuildTimestamp) } \ No newline at end of file