Skip to content

Commit 1f059e0

Browse files
quick update with global version access (#24)
* update for globally accesible version number * update * update * add flag * add flag --------- Co-authored-by: Matt Spurrier <matthew@senseict.com.au> Co-authored-by: HikariKnight <2557889+HikariKnight@users.noreply.github.com>
1 parent 55bfb36 commit 1f059e0

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.goreleaser.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ builds:
1818
- linux
1919
goarch:
2020
- amd64
21-
ldflags:
22-
- -s -w -X version.Version={{ .Tag }}
2321
mod_timestamp: "{{ .CommitTimestamp }}"
24-
22+
ldflags:
23+
- -s -w -X github.com/HikariKnight/quickpassthrough/internal/version.Version={{.Version}}
2524
archives:
2625
- format: tar.gz
2726
# this name template makes the OS and Arch compatible with the results of `uname`.

cmd/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56

67
internal "github.com/HikariKnight/quickpassthrough/internal"
78
downloader "github.com/HikariKnight/quickpassthrough/internal/ls_iommu_downloader"
@@ -13,9 +14,13 @@ func main() {
1314
// Get all our arguments in 1 neat struct
1415
pArg := params.NewParams()
1516

17+
// Display the version
1618
if pArg.Flag["version"] {
17-
fmt.Printf("Quickpassthrough version: %s\n", version.Version)
18-
} else {
19+
fmt.Printf("QuickPassthrough Version %s\n", version.Version)
20+
os.Exit(0)
21+
}
22+
23+
if !pArg.Flag["gui"] {
1924
downloader.CheckLsIOMMU()
2025
internal.Tui()
2126
}

internal/params/params.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewParams() *Params {
5656
// Add version flag
5757
version := parser.Flag("v", "version", &argparse.Options{
5858
Required: false,
59-
Help: "Display version",
59+
Help: "Display the version",
6060
})
6161

6262
// Parse arguments
@@ -78,9 +78,9 @@ func NewParams() *Params {
7878
}
7979

8080
// Add all parsed arguments to a struct for portability since we will use them all over the program
81+
pArg.addFlag("gui", *gui)
8182
pArg.addFlag("version", *version)
82-
/*pArg.addFlag("gui", *gui)
83-
pArg.addFlag("gpu", *gpu)
83+
/*pArg.addFlag("gpu", *gpu)
8484
pArg.addFlag("usb", *usb)
8585
pArg.addFlag("nic", *nic)
8686
pArg.addFlag("sata", *sata)

0 commit comments

Comments
 (0)