Skip to content

Commit

Permalink
Fix: Show version string
Browse files Browse the repository at this point in the history
  • Loading branch information
soumeh01 committed Nov 13, 2024
1 parent 2285960 commit 1787815
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ var flags struct {

// printVersionAndLicense prints out vidx2pidx current version and its license.
func printVersionAndLicense(file io.Writer) {
fmt.Fprintf(file, "vidx2pidx version %v\n", Version)
fmt.Fprintf(file, "%v\n", License)
fmt.Fprintf(file, "vidx2pidx version %v %v\n", Version, License)
}

// NewCli creates a new instance of vidx2pidx cli.
Expand Down
5 changes: 1 addition & 4 deletions cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -53,9 +52,7 @@ func TestCli(t *testing.T) {
t.Fatal(err)
}

expected := fmt.Sprintf("vidx2pidx version %v\n%v", Version, License)

AssertEqual(t, strings.TrimSpace(string(out)), expected)
AssertEqual(t, strings.Contains(string(out), "vidx2pidx version"), true)
})

t.Run("test continue despite errors", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ all:

$(PROG): $(SOURCES)
@echo Building project
GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.Version=`git describe`" -o $(PROG) ./...
GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.Version=`git describe 2>/dev/null || echo unknown`" -o $(PROG) ./...

run: $(PROG)
@./$(PROG) $(ARGS) || true
Expand Down

0 comments on commit 1787815

Please sign in to comment.