-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (46 loc) · 952 Bytes
/
main.go
File metadata and controls
58 lines (46 loc) · 952 Bytes
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
package main
import (
"fmt"
"os"
"runtime/debug"
"strings"
cowsay "github.com/Code-Hex/Neo-cowsay/v2"
"github.com/foomo/sesamy-cli/cmd"
cmdx "github.com/foomo/sesamy-cli/pkg/cmd"
"github.com/pkg/errors"
)
func main() {
l := cmdx.NewLogger()
root := cmd.NewRoot(l)
root.AddCommand(
cmd.NewConfig(l),
cmd.NewList(l),
cmd.NewDiff(l),
cmd.NewOpen(l),
cmd.NewProvision(l),
cmd.NewTags(l),
cmd.NewTypeScript(l),
cmd.NewVersion(l),
)
say := func(msg string) string {
if say, cerr := cowsay.Say(msg, cowsay.BallonWidth(80)); cerr == nil {
msg = say
}
return msg
}
code := 0
defer func() {
if r := recover(); r != nil {
l.Error(say("It's time to panic"))
l.Error(fmt.Sprintf("%v", r))
l.Error(string(debug.Stack()))
code = 1
}
os.Exit(code)
}()
if err := root.Execute(); err != nil {
l.Error(say(strings.Split(errors.Cause(err).Error(), ":")[0]))
l.Error(err.Error())
code = 1
}
}