Skip to content

Commit 932b720

Browse files
committed
Added version command
1 parent e6d2565 commit 932b720

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

cmd/llm/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type CLI struct {
8080
Chat ChatCmd `cmd:"" help:"Start a chat session"`
8181
Complete CompleteCmd `cmd:"" help:"Complete a prompt"`
8282
Embedding EmbeddingCmd `cmd:"" help:"Generate an embedding"`
83+
Version VersionCmd `cmd:"" help:"Print the version of this tool"`
8384
}
8485

8586
////////////////////////////////////////////////////////////////////////////////

cmd/llm/version.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"runtime"
7+
8+
// Packages
9+
"github.com/mutablelogic/go-llm/pkg/version"
10+
)
11+
12+
///////////////////////////////////////////////////////////////////////////////
13+
// TYPES
14+
15+
type VersionCmd struct{}
16+
17+
///////////////////////////////////////////////////////////////////////////////
18+
// PUBLIC METHODS
19+
20+
// Run the version command
21+
func (cmd *VersionCmd) Run() error {
22+
w := os.Stdout
23+
if version.GitSource != "" {
24+
fmt.Fprintf(w, "Source: https://%v\n", version.GitSource)
25+
}
26+
if version.GitTag != "" || version.GitBranch != "" {
27+
fmt.Fprintf(w, "Version: %v (branch: %q hash:%q)\n", version.GitTag, version.GitBranch, version.GitHash)
28+
}
29+
if version.GoBuildTime != "" {
30+
fmt.Fprintf(w, "Build: %v\n", version.GoBuildTime)
31+
}
32+
fmt.Fprintf(w, "Go: %v (%v/%v)\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
33+
return nil
34+
}

pkg/version/version.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package version
2+
3+
///////////////////////////////////////////////////////////////////////////////
4+
// GLOBALS
5+
6+
var (
7+
GitSource string
8+
GitTag string
9+
GitBranch string
10+
GitHash string
11+
GoBuildTime string
12+
)

0 commit comments

Comments
 (0)