From 222a494dbf610d2b882f8ae68b0bf7eefcd38f99 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Tue, 27 Sep 2022 15:13:17 -0400 Subject: [PATCH] fix --port flag shorthand in test endpoint; error handling (#67) --- cmd/zrok/test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/zrok/test.go b/cmd/zrok/test.go index 4e9b148a..4520e0de 100644 --- a/cmd/zrok/test.go +++ b/cmd/zrok/test.go @@ -38,10 +38,13 @@ func newTestEndpointCommand() *testEndpointCommand { command := &testEndpointCommand{cmd: cmd} var err error if command.t, err = template.ParseFS(endpoint_ui.FS, "index.gohtml"); err != nil { + if !panicInstead { + showError("unable to parse index template", err) + } panic(err) } cmd.Flags().StringVarP(&command.address, "address", "a", "0.0.0.0", "The address for the HTTP listener") - cmd.Flags().Uint16VarP(&command.port, "port", "p", 9090, "The port for the HTTP listener") + cmd.Flags().Uint16VarP(&command.port, "port", "P", 9090, "The port for the HTTP listener") cmd.Run = command.run return command } @@ -49,6 +52,9 @@ func newTestEndpointCommand() *testEndpointCommand { func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) { http.HandleFunc("/", cmd.serveIndex) if err := http.ListenAndServe(fmt.Sprintf("%v:%d", cmd.address, cmd.port), nil); err != nil { + if !panicInstead { + showError("unable to start http listener", err) + } panic(err) } }