Add support for loading ids from file

This commit is contained in:
2024-09-17 11:39:35 +02:00
parent c8822f7dc1
commit 56a355f930

17
main.go
View File

@@ -39,9 +39,26 @@ const (
func main() { func main() {
envfile := flag.String("envfile", ".env", "") envfile := flag.String("envfile", ".env", "")
inputfile := flag.String("if", "", "")
flag.Parse() flag.Parse()
args := flag.Args() args := flag.Args()
if *inputfile != "" {
filehandle, err := os.Open(*inputfile)
if err != nil {
Error.Printf("Error opening input file: %v", err)
return
}
defer filehandle.Close()
fargs, err := io.ReadAll(filehandle)
if err != nil {
Error.Printf("Error reading input file: %v", err)
return
}
sargs := strings.Split(string(fargs), "\r\n")
args = append(args, sargs...)
}
if len(args) == 0 { if len(args) == 0 {
Error.Println("No args specified, please pass space delimited list of workshop ids for downloading") Error.Println("No args specified, please pass space delimited list of workshop ids for downloading")
return return