|
|
@ -37,30 +37,31 @@ var ( |
|
|
|
) |
|
|
|
|
|
|
|
func main() { |
|
|
|
menus := []Menu{} |
|
|
|
path := "./" |
|
|
|
if len(os.Args) == 2 { |
|
|
|
path = os.Args[1] + "/" |
|
|
|
} |
|
|
|
|
|
|
|
for _, mensa := range mensen { |
|
|
|
for _, day := range days { |
|
|
|
menu, err := operate(mensa, day) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
menus = append(menus, menu) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bytes, err := json.Marshal(menus) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
} |
|
|
|
content, err := json.Marshal(menu) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if len(os.Args) == 2 { |
|
|
|
err = writeToFile(bytes) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
err = ioutil.WriteFile(fmt.Sprintf("%s/%s.%s.json", path, mensa, day), content, 0644) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
fmt.Println(string(bytes)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|