-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (44 loc) · 876 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 (
"context"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/alecthomas/kong"
"github.com/lox/bkl/cmd"
)
var (
version string // set by goreleaser
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
log.Println("Shutting down")
signal.Stop(c)
cancel()
}()
if err := run(ctx); err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
}
func run(ctx context.Context) error {
cli := cmd.CLI{}
k := kong.Parse(&cli,
kong.Name("bkl"),
kong.Description("Run your Buildkite pipelines locally (no buildkite.com interaction)"),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
}),
kong.Vars{
"version": version,
})
k.BindTo(ctx, (*context.Context)(nil))
return k.Run(&cli)
}