Skip to content

Commit

Permalink
Merge pull request #167 from mxcoder/issue-158--show-version
Browse files Browse the repository at this point in the history
Add version flag to show the current version of the tool
  • Loading branch information
birdayz authored Nov 3, 2021
2 parents 8f463c4 + f1a4c11 commit 931fafa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v2

- name: Build
run: go build -v ./cmd/kaf
run: go build -v -ldflags "-s -w -X main.version=$GITHUB_REF -X main.commit=${GITHUB_SHA::8}" ./cmd/kaf

- name: Test
run: go test -v ./...
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ yay -S kaf

## Usage

Show the tool version

`kaf --version`

Add a local Kafka with no auth

`kaf config add-cluster local -b localhost:9092`
Expand Down
10 changes: 8 additions & 2 deletions cmd/kaf/kaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ var (
colorableOut io.Writer = colorable.NewColorableStdout()
)

// Will be replaced by GitHub action and by goreleaser
// see https://goreleaser.com/customization/build/
var commit string = "HEAD"
var version string = "latest"

var rootCmd = &cobra.Command{
Use: "kaf",
Short: "Kafka Command Line utility for cluster management",
Use: "kaf",
Short: "Kafka Command Line utility for cluster management",
Version: fmt.Sprintf("%s (%s)", version, commit),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
outWriter = cmd.OutOrStdout()
errWriter = cmd.ErrOrStderr()
Expand Down

0 comments on commit 931fafa

Please sign in to comment.