-
-
Notifications
You must be signed in to change notification settings - Fork 179
/
main.go
40 lines (35 loc) · 822 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
package main
import (
"context"
"errors"
"os"
cli "github.com/livebud/bud/internal/cli"
"github.com/livebud/bud/internal/errs"
"github.com/livebud/bud/internal/once"
"github.com/livebud/bud/package/log/console"
)
//go:generate go run scripts/set-package-json/main.go
// main is bud's entrypoint
func main() {
ctx := context.Background()
if err := run(ctx); err != nil {
console.Error(errs.Format(err))
os.Exit(1)
}
os.Exit(0)
}
// Run the CLI with the default configuration and return any resulting errors.
func run(ctx context.Context) error {
closer := new(once.Closer)
defer closer.Close()
// Initialize the CLI
cli := cli.New(closer)
// Run the cli
if err := cli.Parse(ctx, os.Args[1:]...); err != nil {
if errors.Is(err, context.Canceled) {
return nil
}
return err
}
return nil
}