Skip to content

Commit

Permalink
Add command line arg parsing for day
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-aguilar committed Dec 3, 2021
1 parent 1b8d4dc commit 425178f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@ package main
import (
dayOne "aoc21/pkg/dayOne"
"fmt"
"os"
"strconv"
)

func check(e error) {
if e != nil {
panic(e)
}
}

func main() {
fmt.Println(dayOne.PartOne())
fmt.Println(dayOne.PartTwo())
dayCmd, err := strconv.Atoi(os.Args[1])
check(err)
var p1, p2 int
switch dayCmd {
case 1:
p1 = dayOne.PartOne()
p2 = dayOne.PartTwo()
}
fmt.Printf("Part one: %d \nPart Two: %d \n", p1, p2)
}

0 comments on commit 425178f

Please sign in to comment.