Skip to content

Commit

Permalink
feat: add version cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Sep 3, 2023
1 parent 1169b79 commit 664ee1c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath
ldflags: -s -w -X main.AppVersion={{.Version}} -X main.AppBuildTime={{.Date}}
ldflags: -s -w -X github.com/blacktop/lporg/cmd.AppVersion={{.Version}} -X github.com/blacktop/lporg/cmd.AppBuildTime={{.Date}}

universal_binaries:
- id: darwin
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ Available Commands:
load Load launchpad settings config from `FILE`
revert Revert to launchpad settings backup
save Save current launchpad settings
version Print the version number of lporg

Flags:
-c, --config string config file (default is $HOME/.lporg.yaml)
-c, --config string config file (default is $CONFIG/lporg/config.yaml)
-h, --help help for lporg
--icloud iCloud config
--icloud use iCloud for config
-V, --verbose verbose output

Use "lporg [command] --help" for more information about a command.
Expand Down
43 changes: 43 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright © 2023 blacktop
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"
"strings"

"github.com/spf13/cobra"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Aliases: []string{"v"},
Short: "Print the version number of lporg",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Version: %s, BuildTime: %s\n", strings.TrimSpace(AppVersion), strings.TrimSpace(AppBuildTime))
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit 664ee1c

Please sign in to comment.