Skip to content

Commit

Permalink
quick update with global version access (#24)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Mar 30, 2024
1 parent 55bfb36 commit 1f059e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ builds:
- linux
goarch:
- amd64
ldflags:
- -s -w -X version.Version={{ .Tag }}
mod_timestamp: "{{ .CommitTimestamp }}"

ldflags:
- -s -w -X github.com/HikariKnight/quickpassthrough/internal/version.Version={{.Version}}
archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
Expand Down
9 changes: 7 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"os"

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

// Display the version
if pArg.Flag["version"] {
fmt.Printf("Quickpassthrough version: %s\n", version.Version)
} else {
fmt.Printf("QuickPassthrough Version %s\n", version.Version)
os.Exit(0)
}

if !pArg.Flag["gui"] {
downloader.CheckLsIOMMU()
internal.Tui()
}
Expand Down
6 changes: 3 additions & 3 deletions internal/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewParams() *Params {
// Add version flag
version := parser.Flag("v", "version", &argparse.Options{
Required: false,
Help: "Display version",
Help: "Display the version",
})

// Parse arguments
Expand All @@ -78,9 +78,9 @@ func NewParams() *Params {
}

// Add all parsed arguments to a struct for portability since we will use them all over the program
pArg.addFlag("gui", *gui)

Check failure on line 81 in internal/params/params.go

View workflow job for this annotation

GitHub Actions / goreleaser

undefined: gui
pArg.addFlag("version", *version)
/*pArg.addFlag("gui", *gui)
pArg.addFlag("gpu", *gpu)
/*pArg.addFlag("gpu", *gpu)
pArg.addFlag("usb", *usb)
pArg.addFlag("nic", *nic)
pArg.addFlag("sata", *sata)
Expand Down

0 comments on commit 1f059e0

Please sign in to comment.