package main

import (
	"flag"
	"log"

	"git.bazzel.dev/bmallen/helios/pkg/job"
)

var (
	srcdir      = flag.String("d", "", "source dir")
	src         = flag.String("s", "", "source url")
	ref         = flag.String("r", "", "source url ref")
	f           = flag.String("f", "main.go", "file to run")
	skipcleanup = flag.Bool("skipcleanup", false, "skip auto cleanup")
	report      = flag.Bool("report", false, "output report")
)

func main() {
	flag.Parse()

	j := job.New()

	if !*skipcleanup {
		j.AutoCleanup()
	}

	if srcdir != nil {
		if *srcdir != "" {
			j.SourceDir(*srcdir)
		}
	}

	if src != nil {
		if *src != "" {
			j.Source(*src, *ref)
		}
	}

	j.Run(*f)

	if *report {
		j.Report()
	}

	if j.Error() != nil {
		log.Fatal(j.Error())
	}
}
