forked from nlowe/aoc2020
/
importDay10.go
45 lines (34 loc) · 938 Bytes
/
importDay10.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/day10"
)
func init() {
day := &cobra.Command{
Use: "10",
Short: "Problems for Day 10",
}
a := &cobra.Command{
Use: "a",
Short: "Day 10, Problem A",
Run: func(cmd *cobra.Command, _ []string) {
flag := cmd.Flag("input")
fmt.Printf("Answer: %d\n", day10.A(challenge.FromFileP(flag.Value.String())))
},
}
a.Flags().StringP("input", "i", "./challenge/day10/input.txt", "Input File to read")
day.AddCommand(a)
b := &cobra.Command{
Use: "b",
Short: "Day 10, Problem B",
Run: func(cmd *cobra.Command, _ []string) {
flag := cmd.Flag("input")
fmt.Printf("Answer: %d\n", day10.B(challenge.FromFileP(flag.Value.String())))
},
}
b.Flags().StringP("input", "i", "./challenge/day10/input.txt", "Input File to read")
day.AddCommand(b)
rootCmd.AddCommand(day)
}