From d060b2f1c4c430da6064492e2f6e3a8a48e2fa2a Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 29 Jan 2015 01:25:37 -0500 Subject: [PATCH] Add -o flag and output to public_html --- squigglelog.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/squigglelog.go b/squigglelog.go index 87dc158..15332b8 100644 --- a/squigglelog.go +++ b/squigglelog.go @@ -13,10 +13,11 @@ import ( "encoding/json" ) +var outputPath string = os.Getenv("HOME") + "/public_html/" const entriesPath = "./entries/" const templatesPath = "./templates/" -const outputPath = "./html/" const defaultTemplateFile = "log" +const defaultOutFile = "~log" type Entry struct { Date string @@ -48,11 +49,12 @@ func loadEntry(rawDate string) (*Entry, error) { func main() { fmt.Println() - fmt.Println(" ~log generator v1.0") + fmt.Println(" ~log generator v1.1") fmt.Println() // Get any arguments - templateFilePtr := flag.String("template", defaultTemplateFile, "Tildelog template file (defined name).") + templateFilePtr := flag.String("t", defaultTemplateFile, "Squigglelog template file (defined name).") + outFilePtr := flag.String("o", defaultOutFile, "Squigglelog template file (defined name).") flag.Parse() c := configuration() @@ -80,9 +82,9 @@ func main() { fmt.Printf("Using template %s...\n", *templateFilePtr) - generateLog(entries, *templateFilePtr) + generateLog(entries, *templateFilePtr, *outFilePtr) - fmt.Printf("Finished! Saved to %slog.html\n", outputPath) + fmt.Printf("Finished! Saved to %s%s.html\n", outputPath, *outFilePtr) } type Config struct { @@ -122,8 +124,8 @@ func getEntries() *[]string { return &fileList } -func generateLog(entries []Entry, templateFile string) { - file, err := os.Create(outputPath + "log.html") +func generateLog(entries []Entry, templateFile string, outFile string) { + file, err := os.Create(outputPath + outFile + ".html") if err != nil { panic(err) }