runMainApplication runs the main application
(cmd *cobra.Command, args []string)
| 51 | |
| 52 | // runMainApplication runs the main application |
| 53 | func runMainApplication(cmd *cobra.Command, args []string) error { |
| 54 | opts := getBootstrapOptions(cmd) |
| 55 | |
| 56 | // Bootstrap the application |
| 57 | result, err := bootstrap.Bootstrap(opts) |
| 58 | if err != nil { |
| 59 | return fmt.Errorf("bootstrap failed: %w", err) |
| 60 | } |
| 61 | |
| 62 | // If result is nil, the application should exit (e.g., version flag) |
| 63 | if result == nil { |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | // Start the main application |
| 68 | // Handle application runtime errors differently from CLI usage errors |
| 69 | if err := bootstrap.StartApplication(result); err != nil { |
| 70 | // Application runtime error - exit directly without showing usage |
| 71 | os.Exit(1) |
| 72 | } |
| 73 | |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | // getBootstrapOptions converts cobra flags to BootstrapOptions |
| 78 | func getBootstrapOptions(cmd *cobra.Command) bootstrap.BootstrapOptions { |
nothing calls this directly
no test coverage detected