update for current year

This commit is contained in:
Chris Sexton 2020-11-18 10:49:01 -05:00
parent d5417d4b61
commit e4b21fc080
1 changed files with 6 additions and 5 deletions

View File

@ -6,12 +6,13 @@ import (
"log" "log"
"os" "os"
"strconv" "strconv"
"time"
"code.chrissexton.org/cws/getaoc" "code.chrissexton.org/cws/getaoc"
) )
var year = flag.Int("year", 2019, "event year") var year = flag.Int("year", time.Now().Year(), "event year")
var sessId = flag.String("session", "", "session id") var sessID = flag.String("session", "", "session id")
var file = flag.String("file", "input.txt", "filename (- for stdout)") var file = flag.String("file", "input.txt", "filename (- for stdout)")
const base = "https://adventofcode.com" const base = "https://adventofcode.com"
@ -25,13 +26,13 @@ func main() {
day, _ := strconv.Atoi(flag.Arg(0)) day, _ := strconv.Atoi(flag.Arg(0))
sess, ok := os.LookupEnv("AOC_SESSION") sess, ok := os.LookupEnv("AOC_SESSION")
if !ok && *sessId == "" { if !ok && *sessID == "" {
fmt.Fprintln(os.Stderr, "Error: Must provide a session id.") fmt.Fprintln(os.Stderr, "Error: Must provide a session id.")
return return
} }
if *sessId != "" { if *sessID != "" {
sess = *sessId sess = *sessID
} }
body, err := getaoc.GetInput(sess, *year, day) body, err := getaoc.GetInput(sess, *year, day)