generated from ekristen/go-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
61 lines (51 loc) · 1.5 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
package main
import (
"os"
"path"
"github.com/apex/log"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/ekristen/distillery/pkg/common"
"github.com/ekristen/distillery/pkg/signals"
_ "github.com/ekristen/distillery/pkg/commands/clean"
_ "github.com/ekristen/distillery/pkg/commands/completion"
_ "github.com/ekristen/distillery/pkg/commands/info"
_ "github.com/ekristen/distillery/pkg/commands/install"
_ "github.com/ekristen/distillery/pkg/commands/list"
_ "github.com/ekristen/distillery/pkg/commands/proof"
_ "github.com/ekristen/distillery/pkg/commands/run"
_ "github.com/ekristen/distillery/pkg/commands/uninstall"
)
func main() {
defer func() {
if r := recover(); r != nil {
// log panics forces exit
if _, ok := r.(*logrus.Entry); ok {
os.Exit(1)
}
panic(r)
}
}()
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Usage = `install any binary from ideally any source`
app.Description = `install any binary from ideally any detectable source`
app.Version = common.AppVersion.Summary
app.Authors = []*cli.Author{
{
Name: "Erik Kristensen",
Email: "erik@erikkristensen.com",
},
}
app.Before = common.Before
app.Flags = common.Flags()
app.Commands = common.GetCommands()
app.CommandNotFound = func(context *cli.Context, command string) {
log.Fatalf("command %s not found.", command)
}
app.EnableBashCompletion = true
ctx := signals.SetupSignalContext()
if err := app.RunContext(ctx, os.Args); err != nil {
log.Error(err.Error())
}
}