feat: Add version output
This commit is contained in:
parent
ee45d29e6f
commit
55bfb36522
5 changed files with 27 additions and 7 deletions
|
@ -16,9 +16,10 @@ builds:
|
|||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
|
||||
goarch:
|
||||
- amd64
|
||||
ldflags:
|
||||
- -s -w -X version.Version={{ .Tag }}
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
|
||||
archives:
|
||||
|
@ -44,4 +45,4 @@ upx:
|
|||
enabled: true
|
||||
compress: best
|
||||
lzma: true
|
||||
brute: true
|
||||
brute: true
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
internal "github.com/HikariKnight/quickpassthrough/internal"
|
||||
downloader "github.com/HikariKnight/quickpassthrough/internal/ls_iommu_downloader"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/params"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/version"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Get all our arguments in 1 neat struct
|
||||
pArg := params.NewParams()
|
||||
|
||||
if !pArg.Flag["gui"] {
|
||||
if pArg.Flag["version"] {
|
||||
fmt.Printf("Quickpassthrough version: %s\n", version.Version)
|
||||
} else {
|
||||
downloader.CheckLsIOMMU()
|
||||
internal.Tui()
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/version"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||
"github.com/gookit/color"
|
||||
|
@ -17,7 +19,8 @@ func Welcome() {
|
|||
|
||||
// Write title
|
||||
title := color.New(color.BgHiBlue, color.White, color.Bold)
|
||||
title.Println("Welcome to Quickpassthrough!")
|
||||
title.Printf("Welcome to Quickpassthrough %s!\n", version.Version)
|
||||
logger.Printf("Welcome to Quickpassthrough %s!\n", version.Version)
|
||||
|
||||
// Write welcome message
|
||||
color.Print(
|
||||
|
|
|
@ -48,9 +48,15 @@ func NewParams() *Params {
|
|||
parser := argparse.NewParser("quickpassthrough", "A utility to help you configure your host for GPU Passthrough")
|
||||
|
||||
// Configure arguments
|
||||
gui := parser.Flag("g", "gui", &argparse.Options{
|
||||
/*gui := parser.Flag("g", "gui", &argparse.Options{
|
||||
Required: false,
|
||||
Help: "Launch GUI (placeholder for now)",
|
||||
})*/
|
||||
|
||||
// Add version flag
|
||||
version := parser.Flag("v", "version", &argparse.Options{
|
||||
Required: false,
|
||||
Help: "Display version",
|
||||
})
|
||||
|
||||
// Parse arguments
|
||||
|
@ -72,8 +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)
|
||||
/*pArg.addFlag("gpu", *gpu)
|
||||
pArg.addFlag("version", *version)
|
||||
/*pArg.addFlag("gui", *gui)
|
||||
pArg.addFlag("gpu", *gpu)
|
||||
pArg.addFlag("usb", *usb)
|
||||
pArg.addFlag("nic", *nic)
|
||||
pArg.addFlag("sata", *sata)
|
||||
|
|
4
internal/version/version.go
Normal file
4
internal/version/version.go
Normal file
|
@ -0,0 +1,4 @@
|
|||
package version
|
||||
|
||||
// This is automatically set in CI using -ldflags="-X github.com/HikariKnight/quickpassthrough/internal/version.Version=${TAG}" as a build argument
|
||||
var Version string
|
Loading…
Add table
Add a link
Reference in a new issue