From ad30f6ea0f5c266df0c537558cd62d7e9aba50b1 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 13 Aug 2018 20:25:48 +1000 Subject: [PATCH] Changed to follow Cobra convention for version flag on cli To get the version you now have to use `--version` flag instead of the `version` sub-command. Fixes: https://github.com/vibrato/TechTestApp/issues/12 --- .circleci/config.yml | 2 +- cmd/root.go | 1 + cmd/version.go | 41 ----------------------------------------- doc/readme.md | 2 +- 4 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 cmd/version.go diff --git a/.circleci/config.yml b/.circleci/config.yml index 86f4a8e7..04621bc4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,7 +31,7 @@ jobs: mkdir output go build -v -o TechTestApp . ls - ./TechTestApp version | sed -e 's/Version: /v./' > versionfile + ./TechTestApp --version | sed -e 's/TechTestApp version /v./' > versionfile - run: diff --git a/cmd/root.go b/cmd/root.go index f725b447..278f73a0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -54,6 +54,7 @@ var rootCmd = &cobra.Command{ This application is used as part of testing potential candiates at Vibrato. Please visit http://vibrato.com.au for more details`, + Version: "0.3.1", } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/cmd/version.go b/cmd/version.go deleted file mode 100644 index 5799930a..00000000 --- a/cmd/version.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright © 2018 Thomas Winsnes -// -// 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 cmd - -import ( - "fmt" - - "github.com/spf13/cobra" -) - -// versionCmd represents the version command -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Displays the current version", - Long: `Displays the current version of the application`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Version: 0.3.0") - }, -} - -func init() { - rootCmd.AddCommand(versionCmd) -} diff --git a/doc/readme.md b/doc/readme.md index 2c64a790..9c769468 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -120,7 +120,7 @@ Continuous integration is managed through circleci and the build on the master b Releases are deployed and managed through github, it's an automated process that is executed through the CI solution -To create a new release, update `../cmd/version.go` with the new version and merge that into the master branch. +To create a new release, update `../cmd/root.go` with the new version and merge that into the master branch. The commit message on the merge, will be the release message, so make sure it contains the release notes.