Skip to content

Commit 408c74e

Browse files
authored
refactor: Leverage Cobra's Version: for --version reporting (#4)
1 parent c4aac6b commit 408c74e

2 files changed

Lines changed: 1 addition & 14 deletions

File tree

.goreleaser.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ builds:
2323
- -s -w
2424
- -X main.version={{.Version}}
2525
- -X main.commit={{.Commit}}
26-
- -X main.date={{.Date}}
2726

2827
archives:
2928
- formats: [tar.gz]

cmd/remoteproc-simulator/main.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
var (
1515
version = "dev"
1616
commit = "none"
17-
date = "unknown"
1817
)
1918

2019
func main() {
@@ -44,19 +43,8 @@ Example usage:
4443
echo stop > /tmp/fake-root/sys/class/remoteproc/remoteproc0/state
4544
cat /tmp/fake-root/sys/class/remoteproc/remoteproc0/state # Shows 'offline'
4645
`,
46+
Version: fmt.Sprintf("%s (commit: %s)", version, commit),
4747
RunE: func(cmd *cobra.Command, args []string) error {
48-
if showVersion {
49-
fmt.Println("remoteproc-simulator")
50-
fmt.Printf(" version: %s\n", version)
51-
if commit != "none" {
52-
fmt.Printf(" commit: %s\n", commit)
53-
}
54-
if date != "unknown" {
55-
fmt.Printf(" built at: %s\n", date)
56-
}
57-
os.Exit(0)
58-
}
59-
6048
if !cmd.Flags().Changed("root-dir") {
6149
tmpDir, err := os.MkdirTemp("", "remoteproc-simulator-*")
6250
if err != nil {

0 commit comments

Comments
 (0)