Skip to content

Commit

Permalink
Merge pull request #50 from dewe/pr-add-version-command
Browse files Browse the repository at this point in the history
Add version command showing current sinker version
  • Loading branch information
acastle authored Oct 13, 2021
2 parents 6c094eb + c5041d5 commit 745e50d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: build
build:
@go build
@go build -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$$(git describe --tags --always --dirty)'"

.PHONY: test
.PHONY: test
test:
@go test -v ./... -count=1

Expand Down
1 change: 1 addition & 0 deletions internal/commands/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewDefaultCommand() *cobra.Command {
cmd.AddCommand(newPullCommand())
cmd.AddCommand(newPushCommand())
cmd.AddCommand(newCheckCommand())
cmd.AddCommand(newVersionCommand())

return &cmd
}
31 changes: 31 additions & 0 deletions internal/commands/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package commands

import (
"fmt"

"github.com/spf13/cobra"
)

func newVersionCommand() *cobra.Command {
cmd := cobra.Command{
Use: "version",
Short: "The version of sinker",

RunE: func(cmd *cobra.Command, args []string) error {
if err := runVersionCommand(); err != nil {
return fmt.Errorf("list: %w", err)
}

return nil
},
}

cmd.Flags().StringP("output", "o", "", "Output the images in the manifest to a file")

return &cmd
}

func runVersionCommand() error {
fmt.Println("sinker version " + sinkerVersion)
return nil
}

0 comments on commit 745e50d

Please sign in to comment.