-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
52 lines (40 loc) · 926 Bytes
/
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
package main
import (
"os"
"github.com/alecthomas/kong"
log "github.com/sirupsen/logrus"
CLI "github.com/cremindes/whalelint/cli"
RuleSet "github.com/cremindes/whalelint/linter/ruleset"
)
func main() {
log.SetLevel(log.DebugLevel)
log.Debug("We have", RuleSet.Get().Count(), "ruleset.")
// Get arguments
args := os.Args[1:]
cli := CLI.WhaleLintCLI{}
// Create our CLI
parser := kong.Must(&cli, cli.Options()...)
// If no argument is given, show help/usage
if len(args) == 0 {
args = []string{"--help"}
}
// Parse arguments
ctx, err := parser.Parse(args)
// Use lint as default command if none is given
if err != nil {
cli.ApplyDefaultCommand(err, &args)
ctx, err = parser.Parse(args)
if err != nil {
// log.Error(err)
parser.FatalIfErrorf(err)
os.Exit(1)
}
}
// Run command selected by CLI
err = ctx.Run(
kong.Name("WhaleLint"),
)
if err != nil {
log.Error(err)
}
}