Skip to content

Commit

Permalink
Add --iyokan-args option for raw Iyokan arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed May 12, 2020
1 parent 404be0b commit 6468419
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions kvsp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ import (

var flagVerbose bool

// Flag for a list of values
// Thanks to: https://stackoverflow.com/a/28323276
type arrayFlags []string

func (i *arrayFlags) String() string {
return "my string representation"
}

func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}

func fatalExit(err error) {
log.Fatal(err)
os.Exit(1)
Expand Down Expand Up @@ -232,13 +245,14 @@ func runIyokanPacket(args ...string) (string, error) {
return outCmd(path, args)
}

func runIyokan(args ...string) error {
func runIyokan(args0 []string, args1 []string) error {
iyokanPath, err := getPathOf("IYOKAN")
if err != nil {
return err
}

// Run iyokan
args := append(args0, args1...)
return execCmd(iyokanPath, args)
}

Expand Down Expand Up @@ -436,7 +450,9 @@ func doEmu() error {
fs := flag.NewFlagSet("emu", flag.ExitOnError)
var (
whichCAHPCPU = fs.String("cahp-cpu", "emerald", "Which CAHP CPU you use, emerald or diamond")
iyokanArgs arrayFlags
)
fs.Var(&iyokanArgs, "iyokan-args", "Raw arguments for Iyokan")
err := fs.Parse(os.Args[2:])

// Create tmp file for packing
Expand Down Expand Up @@ -464,7 +480,7 @@ func doEmu() error {
if err != nil {
return err
}
err = runIyokan("plain", "-i", packedFile.Name(), "-o", resTmpFile.Name(), "--blueprint", blueprint)
err = runIyokan([]string{"plain", "-i", packedFile.Name(), "-o", resTmpFile.Name(), "--blueprint", blueprint}, iyokanArgs)
if err != nil {
return err
}
Expand Down Expand Up @@ -655,7 +671,9 @@ func doRun() error {
outputFileName = fs.String("o", "", "Output file name (encrypted)")
numGPU = fs.Uint("g", 0, "Number of GPUs (Unspecify or set 0 for CPU mode)")
whichCAHPCPU = fs.String("cahp-cpu", "emerald", "Which CAHP CPU you use, emerald or diamond")
iyokanArgs arrayFlags
)
fs.Var(&iyokanArgs, "iyokan-args", "Raw arguments for Iyokan")
err := fs.Parse(os.Args[2:])
if err != nil {
return err
Expand All @@ -679,7 +697,7 @@ func doRun() error {
if *numGPU > 0 {
args = append(args, "--enable-gpu", "--gpu_num", fmt.Sprint(*numGPU))
}
return runIyokan(args...)
return runIyokan(args, iyokanArgs)
}

var kvspVersion = "unk"
Expand Down

0 comments on commit 6468419

Please sign in to comment.