From da964805491a2a0cd6dafdf6117a895954c3b29b Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 9 Aug 2019 20:15:00 -0400 Subject: [PATCH] Move days/classes to args --- generate.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/generate.go b/generate.go index e83c314..f7e7b3e 100644 --- a/generate.go +++ b/generate.go @@ -7,16 +7,19 @@ import ( "log" "os" "os/exec" + "strings" "text/template" "time" ) var ( - fileName = flag.String("file", "output", "Name of output file") - tplPath = flag.String("tpl", "daily", "Path to templates") - startDate = flag.String("start", "", "date of start (yyy-mm-dd)") - pages = flag.Int("pages", 7, "number of pages") - debug = flag.Bool("debug", false, "leave LaTeX log files") + fileName = flag.String("file", "output", "Name of output file") + tplPath = flag.String("tpl", "daily", "Path to templates") + startDate = flag.String("start", "", "date of start (yyy-mm-dd)") + courseDays = flag.String("courseDays", "Monday,Wednesday,Other", "days for the class template") + courses = flag.String("courses", "Cxxx,Cyyy,Czzz", "courses for the class template") + pages = flag.Int("pages", 7, "number of pages") + debug = flag.Bool("debug", false, "leave LaTeX log files") ) func main() { @@ -65,8 +68,8 @@ func class(file *os.File) { check(head.Execute(file, nil)) for i := 0; i < *pages; i++ { info := map[string]interface{}{ - "Courses": []string{"C311", "C346", "C490"}, - "Days": []string{"Monday", "Wednesday", "Other"}, + "Courses": strings.Split(*courses, ","), + "Days": strings.Split(*courseDays, ","), "DateRange": fmt.Sprintf("%s-%s", day.Format("2006/01/02"), day.Add(24*time.Hour).Format("02")), "Week": fmt.Sprintf("Week %d", i+1), }