initial commit to prepare for rewrite into golang for actual use
This commit is contained in:
parent
0d4f63f371
commit
5da1a88296
21 changed files with 129 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ config/
|
||||||
backup/
|
backup/
|
||||||
utils/
|
utils/
|
||||||
utils.old/
|
utils.old/
|
||||||
|
bin/
|
29
.goreleaser.yaml
Normal file
29
.goreleaser.yaml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx "{{ .Path }}"
|
||||||
|
archives:
|
||||||
|
- replacements:
|
||||||
|
linux: Linux
|
||||||
|
amd64: x86_64
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}-next"
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
||||||
|
|
||||||
|
# modelines, feel free to remove those if you don't want/use them:
|
||||||
|
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||||
|
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
1
cmd/main.go
Normal file
1
cmd/main.go
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package main
|
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module github.com/HikariKnight/quickpassthrough
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require github.com/akamensky/argparse v1.4.0
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/akamensky/argparse v1.4.0 h1:YGzvsTqCvbEZhL8zZu2AiA5nq805NZh75JNj4ajn1xc=
|
||||||
|
github.com/akamensky/argparse v1.4.0/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
90
pkg/params/params.go
Normal file
90
pkg/params/params.go
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
package params
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/akamensky/argparse"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
The whole purpose of this module is to make a struct
|
||||||
|
to just carry all our parsed arguments around between functions
|
||||||
|
|
||||||
|
Create a Params struct with all the argparse arguments
|
||||||
|
pArg := params.NewParams()
|
||||||
|
*/
|
||||||
|
|
||||||
|
type Params struct {
|
||||||
|
Flag map[string]bool
|
||||||
|
FlagCounter map[string]int
|
||||||
|
IntList map[string][]int
|
||||||
|
StringList map[string][]string
|
||||||
|
String map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Params) addFlag(name string, flag bool) {
|
||||||
|
p.Flag[name] = flag
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Params) addFlagCounter(name string, flag int) {
|
||||||
|
p.FlagCounter[name] = flag
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Params) addIntList(name string, flag []int) {
|
||||||
|
p.IntList[name] = flag
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Params) addStringList(name string, flag []string) {
|
||||||
|
p.StringList[name] = flag
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Params) addString(name string, flag string) {
|
||||||
|
p.String[name] = flag
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewParams() *Params {
|
||||||
|
// Setup the parser for arguments
|
||||||
|
parser := argparse.NewParser("quickpassthrough", "A utility to help you configure your host for GPU Passthrough")
|
||||||
|
|
||||||
|
// Configure arguments
|
||||||
|
/*gpu := parser.Flag("g", "gpu", &argparse.Options{
|
||||||
|
Required: false,
|
||||||
|
Help: "List all GPUs. (use -i # to only display results from specified IOMMU group)",
|
||||||
|
})*/
|
||||||
|
|
||||||
|
// Parse arguments
|
||||||
|
err := parser.Parse(os.Args)
|
||||||
|
if err != nil {
|
||||||
|
// In case of error print error and print usage
|
||||||
|
// This can also be done by passing -h or --help flags
|
||||||
|
fmt.Print(parser.Usage(err))
|
||||||
|
os.Exit(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make our struct
|
||||||
|
pArg := &Params{
|
||||||
|
Flag: make(map[string]bool),
|
||||||
|
FlagCounter: make(map[string]int),
|
||||||
|
IntList: make(map[string][]int),
|
||||||
|
StringList: make(map[string][]string),
|
||||||
|
String: make(map[string]string),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add all parsed arguments to a struct for portability since we will use them all over the program
|
||||||
|
/*pArg.addFlag("gpu", *gpu)
|
||||||
|
pArg.addFlag("usb", *usb)
|
||||||
|
pArg.addFlag("nic", *nic)
|
||||||
|
pArg.addFlag("sata", *sata)
|
||||||
|
pArg.addFlagCounter("related", *related)
|
||||||
|
pArg.addStringList("ignore", *ignore)
|
||||||
|
pArg.addIntList("iommu_group", *iommu_group)
|
||||||
|
pArg.addFlag("kernelmodules", *kernelmodules)
|
||||||
|
pArg.addFlag("legacyoutput", *legacyoutput)
|
||||||
|
pArg.addFlag("id", *id)
|
||||||
|
pArg.addFlag("pciaddr", *pciaddr)
|
||||||
|
pArg.addFlag("rom", *rom)
|
||||||
|
pArg.addString("format", *format)*/
|
||||||
|
|
||||||
|
return pArg
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue