-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
52 lines (43 loc) · 1.19 KB
/
main.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
46
47
48
49
50
51
52
// aoc-cli is a tool to run solutions to get answers for input on advent-of-code site.
package main
import (
"context"
"errors"
"os"
log "github.com/obalunenko/logger"
"github.com/urfave/cli/v2"
_ "github.com/obalunenko/advent-of-code/internal/puzzles/solutions" // register all solutions.
)
const (
exit = "exit"
back = "back"
pageSize = 10
abort = "^C"
)
var errExit = errors.New("exit is chosen")
func main() {
ctx := context.Background()
app := cli.NewApp()
app.Name = "aoc-cli"
app.Description = "Solutions of puzzles for Advent Of Code (https://adventofcode.com/)\n" +
"This command line tool contains solutions for puzzles and cli tool to run solutions to get " +
"answers for input on site."
app.Usage = `a command line tool for get solution for Advent of Code puzzles`
app.Authors = []*cli.Author{
{
Name: "Oleg Balunenko",
Email: "oleg.balunenko@gmail.com",
},
}
app.CommandNotFound = notFound(ctx)
app.Commands = commands(ctx)
app.Version = printVersion(ctx)
app.Before = printHeader(ctx)
app.After = onExit(ctx)
if err := app.Run(os.Args); err != nil {
if errors.Is(err, errExit) {
return
}
log.WithError(ctx, err).Fatal("Run failed")
}
}