()
| 17 | ) |
| 18 | |
| 19 | func main() { |
| 20 | var exitCode int |
| 21 | defer panichandler.HandlePanic() |
| 22 | |
| 23 | config, err := configv3.GetCFConfig() |
| 24 | if err != nil { |
| 25 | fmt.Fprintf(os.Stderr, "Unexpected error: %s\n", err.Error()) |
| 26 | os.Exit(1) |
| 27 | } |
| 28 | |
| 29 | commandUI, err := ui.NewUI(config) |
| 30 | if err != nil { |
| 31 | fmt.Fprintf(os.Stderr, "Unexpected error: %s\n", err.Error()) |
| 32 | os.Exit(1) |
| 33 | } |
| 34 | |
| 35 | p, err := command_parser.NewCommandParser(config) |
| 36 | if err != nil { |
| 37 | fmt.Fprintf(os.Stderr, "Unexpected error: %s\n", err.Error()) |
| 38 | os.Exit(1) |
| 39 | } |
| 40 | |
| 41 | exitCode, err = p.ParseCommandFromArgs(commandUI, os.Args[1:]) |
| 42 | if err == nil { |
| 43 | os.Exit(exitCode) |
| 44 | } |
| 45 | |
| 46 | if unknownCommandError, ok := err.(command_parser.UnknownCommandError); ok { |
| 47 | plugin, commandIsPlugin := plugin_util.IsPluginCommand(os.Args[1:]) |
| 48 | |
| 49 | switch { |
| 50 | case commandIsPlugin: |
| 51 | err = plugin_util.RunPlugin(plugin) |
| 52 | if err != nil { |
| 53 | exitCode = 1 |
| 54 | } |
| 55 | |
| 56 | case common.ShouldFallbackToLegacy: |
| 57 | cmd.Main(os.Getenv("CF_TRACE"), os.Args) |
| 58 | // NOT REACHED, legacy main will exit the process |
| 59 | |
| 60 | default: |
| 61 | unknownCommandError.Suggest(plugin_util.PluginCommandNames()) |
| 62 | fmt.Fprintf(os.Stderr, "%s\n", unknownCommandError.Error()) |
| 63 | os.Exit(1) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | os.Exit(exitCode) |
| 68 | } |
nothing calls this directly
no test coverage detected