()
| 33 | ) |
| 34 | |
| 35 | func main() { |
| 36 | // Couldn't find an easier way to disable the timestamp. |
| 37 | // Enable color on interactive terminals and CI systems that render ANSI, |
| 38 | // and disable it for ANSI-incapable consumers (e.g. a Jenkins console |
| 39 | // without the AnsiColor plugin, piped output) to avoid leaking raw escape |
| 40 | // codes. See cmd.LogColorDisabled. |
| 41 | logger := zerolog.New(zerolog.ConsoleWriter{ |
| 42 | Out: os.Stderr, |
| 43 | NoColor: cmd.LogColorDisabled(), |
| 44 | FormatTimestamp: func(interface{}) string { return "" }, |
| 45 | }) |
| 46 | rootCmd := cmd.NewRootCmd(logger) |
| 47 | if err := cmd.Execute(rootCmd); err != nil { |
| 48 | msg, exitCode := errorInfo(err, logger) |
| 49 | logger.Error().Msg(msg) |
| 50 | os.Exit(exitCode) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | // handle predefined errors and handle types so we can tailor the experience |
| 55 | func errorInfo(err error, logger zerolog.Logger) (string, int) { |
nothing calls this directly
no test coverage detected