forked from nlowe/aoc2020
/
importDay3.go
45 lines (34 loc) · 929 Bytes
/
importDay3.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/heldeen/aoc2020/challenge"
"github.com/heldeen/aoc2020/challenge/day3"
)
func init() {
day := &cobra.Command{
Use: "3",
Short: "Problems for Day 3",
}
a := &cobra.Command{
Use: "a",
Short: "Day 3, Problem A",
Run: func(cmd *cobra.Command, _ []string) {
flag := cmd.Flag("input")
fmt.Printf("Answer: %d\n", day3.A(challenge.FromFileP(flag.Value.String())))
},
}
a.Flags().StringP("input", "i", "./challenge/day3/input.txt", "Input File to read")
day.AddCommand(a)
b := &cobra.Command{
Use: "b",
Short: "Day 3, Problem B",
Run: func(cmd *cobra.Command, _ []string) {
flag := cmd.Flag("input")
fmt.Printf("Answer: %d\n", day3.B(challenge.FromFileP(flag.Value.String())))
},
}
b.Flags().StringP("input", "i", "./challenge/day3/input.txt", "Input File to read")
day.AddCommand(b)
rootCmd.AddCommand(day)
}