Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/UnitVectorY-Labs/clip4llm

go 1.26 // GOVERSION
go 1.26.0 // GOVERSION

require github.com/atotto/clipboard v0.1.4

Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/fs"
"log"
"os"
"runtime"
"runtime/debug"
"path/filepath"
"strings"
Expand Down Expand Up @@ -47,7 +48,7 @@ func main() {
flag.Parse()

if *showVersion {
fmt.Println("Version:", Version)
fmt.Println(formatVersionOutput("clip4llm", Version))
return
}

Expand Down Expand Up @@ -397,3 +398,10 @@ func parseCommaSeparated(input string) []string {
}
return result
}

func formatVersionOutput(projectName, version string) string {
if version != "" && !strings.HasPrefix(version, "v") {
version = "v" + version
}
return fmt.Sprintf("%s version %s (%s, %s/%s)", projectName, version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
}
34 changes: 33 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
package main

import "testing"
import (
"fmt"
"runtime"
"testing"
)

// TestGreet is a basic unit test for the Greet function
func TestGreet(t *testing.T) {
main()
}

func TestFormatVersionOutput(t *testing.T) {
tests := []struct {
name string
version string
want string
}{
{
name: "adds v prefix when missing",
version: "1.2.3",
want: fmt.Sprintf("clip4llm version v1.2.3 (%s, %s/%s)", runtime.Version(), runtime.GOOS, runtime.GOARCH),
},
{
name: "preserves existing v prefix",
version: "v2.3.4",
want: fmt.Sprintf("clip4llm version v2.3.4 (%s, %s/%s)", runtime.Version(), runtime.GOOS, runtime.GOARCH),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := formatVersionOutput("clip4llm", tt.version)
if got != tt.want {
t.Fatalf("formatVersionOutput() = %q, want %q", got, tt.want)
}
})
}
}