-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
53 lines (40 loc) · 1.16 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
// copyright © 2022 benleb <[email protected]>
package main
import (
"fmt"
"os"
"os/signal"
"github.com/benleb/gloomberg/cmd"
"github.com/benleb/gloomberg/internal"
"github.com/benleb/gloomberg/internal/style"
"github.com/charmbracelet/lipgloss"
"github.com/ethereum/go-ethereum/log"
"github.com/muesli/termenv"
)
var version = "dev"
func main() {
internal.GloombergVersion = version
// cmd.BuildDate = buildDate
// cmd.BuiltBy = builtBy
// save default foreground color and change it to light gray
defaultForeground := termenv.ForegroundColor()
lipgloss.SetColorProfile(termenv.TrueColor)
termenv.DefaultOutput().SetForegroundColor(termenv.RGBColor(style.LightGrayForeground))
// signal handler channel
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
sig := <-c
// ctrl+c handler
log.Debug(fmt.Sprintf("Got %s signal. Aborting...\n", sig))
// if err := client.Disconnect(context.TODO()); err != nil {
// panic(err)
// }
cmd.GracefulShutdown()
// reset/restore default foreground color
termenv.DefaultOutput().SetForegroundColor(defaultForeground)
termenv.DefaultOutput().Reset()
os.Exit(0)
}()
cmd.Execute()
}