-
Notifications
You must be signed in to change notification settings - Fork 1
/
smolgit.go
43 lines (38 loc) · 836 Bytes
/
smolgit.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
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"smolgit/cmd"
"smolgit/pkg/config"
)
var (
version = "dev"
configPath = flag.String("config", "./config.yaml", "path to config")
)
func main() {
flag.Parse()
command := os.Args[1:]
if len(command) > 0 && command[0] == "config" {
cfg, err := config.GenerateConfig()
if err != nil {
log.Fatalf("failed to generate config: %s", err)
}
fmt.Print(string(cfg))
os.Exit(0)
}
sigchnl := make(chan os.Signal, 1)
signal.Notify(sigchnl, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
exitchnl := make(chan os.Signal)
app, err := cmd.New(version, configPath, exitchnl, sigchnl)
if err != nil {
log.Fatalf("failed to init app: %s", err)
}
if err := app.Run(); err != nil {
log.Fatalf("failed to start app: %s", err)
}
<-exitchnl
}