Skip to content

Commit 55bfb36

Browse files
committed
feat: Add version output
1 parent ee45d29 commit 55bfb36

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

.goreleaser.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ builds:
1616
- CGO_ENABLED=0
1717
goos:
1818
- linux
19-
2019
goarch:
2120
- amd64
21+
ldflags:
22+
- -s -w -X version.Version={{ .Tag }}
2223
mod_timestamp: "{{ .CommitTimestamp }}"
2324

2425
archives:
@@ -44,4 +45,4 @@ upx:
4445
enabled: true
4546
compress: best
4647
lzma: true
47-
brute: true
48+
brute: true

cmd/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package main
22

33
import (
4+
"fmt"
5+
46
internal "github.com/HikariKnight/quickpassthrough/internal"
57
downloader "github.com/HikariKnight/quickpassthrough/internal/ls_iommu_downloader"
68
"github.com/HikariKnight/quickpassthrough/internal/params"
9+
"github.com/HikariKnight/quickpassthrough/internal/version"
710
)
811

912
func main() {
1013
// Get all our arguments in 1 neat struct
1114
pArg := params.NewParams()
1215

13-
if !pArg.Flag["gui"] {
16+
if pArg.Flag["version"] {
17+
fmt.Printf("Quickpassthrough version: %s\n", version.Version)
18+
} else {
1419
downloader.CheckLsIOMMU()
1520
internal.Tui()
1621
}

internal/pages/01_welcome.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"os"
66

77
"github.com/HikariKnight/quickpassthrough/internal/configs"
8+
"github.com/HikariKnight/quickpassthrough/internal/logger"
9+
"github.com/HikariKnight/quickpassthrough/internal/version"
810
"github.com/HikariKnight/quickpassthrough/pkg/command"
911
"github.com/HikariKnight/quickpassthrough/pkg/menu"
1012
"github.com/gookit/color"
@@ -17,7 +19,8 @@ func Welcome() {
1719

1820
// Write title
1921
title := color.New(color.BgHiBlue, color.White, color.Bold)
20-
title.Println("Welcome to Quickpassthrough!")
22+
title.Printf("Welcome to Quickpassthrough %s!\n", version.Version)
23+
logger.Printf("Welcome to Quickpassthrough %s!\n", version.Version)
2124

2225
// Write welcome message
2326
color.Print(

internal/params/params.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ func NewParams() *Params {
4848
parser := argparse.NewParser("quickpassthrough", "A utility to help you configure your host for GPU Passthrough")
4949

5050
// Configure arguments
51-
gui := parser.Flag("g", "gui", &argparse.Options{
51+
/*gui := parser.Flag("g", "gui", &argparse.Options{
5252
Required: false,
5353
Help: "Launch GUI (placeholder for now)",
54+
})*/
55+
56+
// Add version flag
57+
version := parser.Flag("v", "version", &argparse.Options{
58+
Required: false,
59+
Help: "Display version",
5460
})
5561

5662
// Parse arguments
@@ -72,8 +78,9 @@ func NewParams() *Params {
7278
}
7379

7480
// Add all parsed arguments to a struct for portability since we will use them all over the program
75-
pArg.addFlag("gui", *gui)
76-
/*pArg.addFlag("gpu", *gpu)
81+
pArg.addFlag("version", *version)
82+
/*pArg.addFlag("gui", *gui)
83+
pArg.addFlag("gpu", *gpu)
7784
pArg.addFlag("usb", *usb)
7885
pArg.addFlag("nic", *nic)
7986
pArg.addFlag("sata", *sata)

internal/version/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package version
2+
3+
// This is automatically set in CI using -ldflags="-X github.com/HikariKnight/quickpassthrough/internal/version.Version=${TAG}" as a build argument
4+
var Version string

0 commit comments

Comments
 (0)