main.go 713 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //go:build cli
  2. // +build cli
  3. package main
  4. import (
  5. "fmt"
  6. "os"
  7. "time"
  8. "github.com/fatih/color"
  9. "github.com/getsentry/sentry-go"
  10. "github.com/porter-dev/porter/cli/cmd"
  11. "github.com/porter-dev/porter/cli/cmd/config"
  12. "github.com/porter-dev/porter/cli/cmd/errors"
  13. )
  14. func main() {
  15. if errors.SentryDSN != "" {
  16. fmt.Println("initialising sentry")
  17. err := sentry.Init(sentry.ClientOptions{
  18. Dsn: errors.SentryDSN,
  19. Environment: "cli",
  20. Debug: config.Version == "dev",
  21. Release: config.Version,
  22. })
  23. if err != nil {
  24. color.New(color.FgRed).Fprintf(os.Stderr, "error initialising sentry: %s\n", err)
  25. os.Exit(1)
  26. }
  27. defer sentry.Flush(2 * time.Second)
  28. }
  29. cmd.Execute()
  30. }