From 405e1c847caea48b1f30cdef44723dff84655043 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 15 Feb 2023 21:06:00 -0500 Subject: [PATCH] more prg nil checks --- cmd/zrok/enable.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/zrok/enable.go b/cmd/zrok/enable.go index 1328f4c8..e1bcbb99 100644 --- a/cmd/zrok/enable.go +++ b/cmd/zrok/enable.go @@ -104,24 +104,32 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) { cmd.endpointError(zrd.ApiEndpoint()) os.Exit(1) } - prg.Send("writing the environment details...") + if err != nil { + prg.Send("writing the environment details...") + } apiEndpoint, _ := zrd.ApiEndpoint() zrd.Env = &zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint} if err := zrd.Save(); err != nil { - prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err)) - prg.Quit() + if prg != nil { + prg.Send(fmt.Sprintf("there was an error saving the new environment: %v", err)) + prg.Quit() + } <-done os.Exit(1) } if err := zrokdir.SaveZitiIdentity("backend", resp.Payload.Cfg); err != nil { - prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err)) - prg.Quit() + if prg != nil { + prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err)) + prg.Quit() + } <-done os.Exit(1) } - prg.Send(fmt.Sprintf("the zrok environment was successfully enabled...")) - prg.Quit() + if prg != nil { + prg.Send(fmt.Sprintf("the zrok environment was successfully enabled...")) + prg.Quit() + } <-done }