From 43b5413b7955f0386922bd2fb9f7b45b1c3f8304 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 27 Jan 2015 16:16:32 -0500 Subject: [PATCH] Accept -o (output) flag, extract src path into const --- tablizer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tablizer.go b/tablizer.go index f59828f..6115a60 100644 --- a/tablizer.go +++ b/tablizer.go @@ -4,6 +4,7 @@ import ( "os" "fmt" "time" + "flag" "sort" "bufio" "strconv" @@ -11,11 +12,17 @@ import ( "text/template" ) +const scores = "/home/krowbar/Code/irc/tildescores.txt" + func main() { fmt.Println("Starting...") + // Get any arguments + outPtr := flag.String("o", "tildescores", "Output file name") + flag.Parse() + headers := []string{ "User", "Tildes", "Last Collection" } - generate("tilde collectors", sortScore(readData("/home/krowbar/Code/irc/tildescores.txt", "&^%", headers)), "tildes") + generate("tilde collectors", sortScore(readData(scores, "&^%", headers)), *outPtr) } type Table struct {