Skip to content

Commit c5041d5

Browse files
committed
Add version command showing current sinker version
1 parent 24787be commit c5041d5

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.PHONY: build
22
build:
3-
@go build
3+
@go build -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$$(git describe --tags --always --dirty)'"
44

5-
.PHONY: test
5+
.PHONY: test
66
test:
77
@go test -v ./... -count=1
88

internal/commands/default.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func NewDefaultCommand() *cobra.Command {
3434
cmd.AddCommand(newPullCommand())
3535
cmd.AddCommand(newPushCommand())
3636
cmd.AddCommand(newCheckCommand())
37+
cmd.AddCommand(newVersionCommand())
3738

3839
return &cmd
3940
}

internal/commands/version.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package commands
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func newVersionCommand() *cobra.Command {
10+
cmd := cobra.Command{
11+
Use: "version",
12+
Short: "The version of sinker",
13+
14+
RunE: func(cmd *cobra.Command, args []string) error {
15+
if err := runVersionCommand(); err != nil {
16+
return fmt.Errorf("list: %w", err)
17+
}
18+
19+
return nil
20+
},
21+
}
22+
23+
cmd.Flags().StringP("output", "o", "", "Output the images in the manifest to a file")
24+
25+
return &cmd
26+
}
27+
28+
func runVersionCommand() error {
29+
fmt.Println("sinker version " + sinkerVersion)
30+
return nil
31+
}

0 commit comments

Comments
 (0)