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
|
- CGO_ENABLED=0
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
|
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X version.Version={{ .Tag }}
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
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"
|
||||||
"github.com/HikariKnight/quickpassthrough/internal/params"
|
"github.com/HikariKnight/quickpassthrough/internal/params"
|
||||||
|
"github.com/HikariKnight/quickpassthrough/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Get all our arguments in 1 neat struct
|
// Get all our arguments in 1 neat struct
|
||||||
pArg := params.NewParams()
|
pArg := params.NewParams()
|
||||||
|
|
||||||
if !pArg.Flag["gui"] {
|
if pArg.Flag["version"] {
|
||||||
|
fmt.Printf("Quickpassthrough version: %s\n", version.Version)
|
||||||
|
} else {
|
||||||
downloader.CheckLsIOMMU()
|
downloader.CheckLsIOMMU()
|
||||||
internal.Tui()
|
internal.Tui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
"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/command"
|
||||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||||
"github.com/gookit/color"
|
"github.com/gookit/color"
|
||||||
|
@ -17,7 +19,8 @@ func Welcome() {
|
||||||
|
|
||||||
// Write title
|
// Write title
|
||||||
title := color.New(color.BgHiBlue, color.White, color.Bold)
|
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
|
// Write welcome message
|
||||||
color.Print(
|
color.Print(
|
||||||
|
|
|
@ -48,9 +48,15 @@ func NewParams() *Params {
|
||||||
parser := argparse.NewParser("quickpassthrough", "A utility to help you configure your host for GPU Passthrough")
|
parser := argparse.NewParser("quickpassthrough", "A utility to help you configure your host for GPU Passthrough")
|
||||||
|
|
||||||
// Configure arguments
|
// Configure arguments
|
||||||
gui := parser.Flag("g", "gui", &argparse.Options{
|
/*gui := parser.Flag("g", "gui", &argparse.Options{
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Launch GUI (placeholder for now)",
|
Help: "Launch GUI (placeholder for now)",
|
||||||
|
})*/
|
||||||
|
|
||||||
|
// Add version flag
|
||||||
|
version := parser.Flag("v", "version", &argparse.Options{
|
||||||
|
Required: false,
|
||||||
|
Help: "Display version",
|
||||||
})
|
})
|
||||||
|
|
||||||
// Parse arguments
|
// 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
|
// 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("gpu", *gpu)
|
/*pArg.addFlag("gui", *gui)
|
||||||
|
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)
|
||||||
|
|
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