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>
This commit is contained in:
Matt Spurrier 2024-03-30 22:00:40 +08:00 committed by GitHub
parent 55bfb36522
commit 1f059e0a96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 8 deletions

View file

@ -18,10 +18,9 @@ builds:
- linux - linux
goarch: goarch:
- amd64 - amd64
ldflags:
- -s -w -X version.Version={{ .Tag }}
mod_timestamp: "{{ .CommitTimestamp }}" mod_timestamp: "{{ .CommitTimestamp }}"
ldflags:
- -s -w -X github.com/HikariKnight/quickpassthrough/internal/version.Version={{.Version}}
archives: archives:
- format: tar.gz - format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`. # this name template makes the OS and Arch compatible with the results of `uname`.

View file

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"os"
internal "github.com/HikariKnight/quickpassthrough/internal" internal "github.com/HikariKnight/quickpassthrough/internal"
downloader "github.com/HikariKnight/quickpassthrough/internal/ls_iommu_downloader" downloader "github.com/HikariKnight/quickpassthrough/internal/ls_iommu_downloader"
@ -13,9 +14,13 @@ func main() {
// Get all our arguments in 1 neat struct // Get all our arguments in 1 neat struct
pArg := params.NewParams() pArg := params.NewParams()
// Display the version
if pArg.Flag["version"] { if pArg.Flag["version"] {
fmt.Printf("Quickpassthrough version: %s\n", version.Version) fmt.Printf("QuickPassthrough Version %s\n", version.Version)
} else { os.Exit(0)
}
if !pArg.Flag["gui"] {
downloader.CheckLsIOMMU() downloader.CheckLsIOMMU()
internal.Tui() internal.Tui()
} }

View file

@ -56,7 +56,7 @@ func NewParams() *Params {
// Add version flag // Add version flag
version := parser.Flag("v", "version", &argparse.Options{ version := parser.Flag("v", "version", &argparse.Options{
Required: false, Required: false,
Help: "Display version", Help: "Display the version",
}) })
// Parse arguments // Parse arguments
@ -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 // Add all parsed arguments to a struct for portability since we will use them all over the program
pArg.addFlag("gui", *gui)
pArg.addFlag("version", *version) pArg.addFlag("version", *version)
/*pArg.addFlag("gui", *gui) /*pArg.addFlag("gpu", *gpu)
pArg.addFlag("gpu", *gpu)
pArg.addFlag("usb", *usb) pArg.addFlag("usb", *usb)
pArg.addFlag("nic", *nic) pArg.addFlag("nic", *nic)
pArg.addFlag("sata", *sata) pArg.addFlag("sata", *sata)