41 lines
737 B
Go
41 lines
737 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
|
|
"gitea.nulo.in/Nulo/repro-run/runner"
|
|
"github.com/joho/godotenv"
|
|
"golang.org/x/exp/slices"
|
|
)
|
|
|
|
func main() {
|
|
config, err := readConfig()
|
|
must(err)
|
|
|
|
dontDeleteTemp := slices.Contains(os.Args, "--dont-delete-temp")
|
|
|
|
env, err := godotenv.Read()
|
|
if err != nil {
|
|
log.Printf("Couldn't load env file: %v", err)
|
|
}
|
|
for k, v := range env {
|
|
env[k] = strings.ReplaceAll(v, "\\n", "\n")
|
|
}
|
|
|
|
must(runner.Run(config, "rootfs/", "cache/", ".", nil, dontDeleteTemp, env))
|
|
}
|
|
|
|
func must(err error, where ...string) {
|
|
if err != nil {
|
|
log.Fatal(err, where)
|
|
}
|
|
}
|
|
|
|
func readConfig() (config runner.Config, err error) {
|
|
err = json.NewDecoder(os.Stdin).Decode(&config)
|
|
return
|
|
}
|