-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
83 lines (73 loc) · 1.6 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"bytes"
"github.com/chermehdi/egor/commands"
"github.com/chermehdi/egor/config"
"github.com/urfave/cli/v2"
"html/template"
"io/ioutil"
"log"
"os"
)
const Egor = `
______
/ ____/___ _____ _____
/ __/ / __ / __ \/ ___/
/ /___/ /_/ / /_/ / /
/_____/\__, /\____/_/
/____/ version: {{ .Version }}
|------------------------------------>>
`
var EgorTemplate, _ = template.New("egor").Parse(Egor)
// returns true if `--dev` flag has been supplied
func isDev() bool {
for _, v := range os.Args {
if v == "--dev" {
return true
}
}
return false
}
func main() {
var egor bytes.Buffer
configuration, err := config.LoadDefaultConfiguration()
if err != nil {
log.Fatal(err)
}
err = EgorTemplate.Execute(&egor, configuration)
if err != nil {
log.Fatal(err)
}
// Disable logging if not in trace mode.
if !isDev() {
log.SetOutput(ioutil.Discard)
}
app := &cli.App{
Name: egor.String(),
Usage: "Run egor -help to print usage",
Description: "Competitive programming helper CLI",
UsageText: "Run egor <subcommand> [--flags]*",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "dev",
Usage: "Set to true if you want detailed logs, useful in dev mode.",
Value: false,
},
},
Commands: []*cli.Command{
&commands.ParseCommand,
&commands.ConfigCommand,
&commands.CaseCommand,
&commands.ShowCasesCommand,
&commands.CopyCommand,
&commands.PrintCaseCommand,
&commands.TestCommand,
&commands.CreateTaskCommand,
&commands.BatchCommand,
},
}
err = app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}