@@ -67,22 +67,21 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
6767 return fmt .Errorf ("get Redis instances: %w" , err )
6868 }
6969 instances := * resp .Instances
70- if len (instances ) == 0 {
71- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
72- if err != nil {
73- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
74- projectLabel = model .ProjectId
75- }
76- params .Printer .Info ("No instances found for project %q\n " , projectLabel )
77- return nil
78- }
7970
8071 // Truncate output
8172 if model .Limit != nil && len (instances ) > int (* model .Limit ) {
8273 instances = instances [:* model .Limit ]
8374 }
8475
85- return outputResult (params .Printer , model .OutputFormat , instances )
76+ projectLabel := model .ProjectId
77+ if len (instances ) == 0 {
78+ projectLabel , err = projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
79+ if err != nil {
80+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
81+ }
82+ }
83+
84+ return outputResult (params .Printer , model .OutputFormat , projectLabel , instances )
8685 },
8786 }
8887
@@ -130,7 +129,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *redis.APICl
130129 return req
131130}
132131
133- func outputResult (p * print.Printer , outputFormat string , instances []redis.Instance ) error {
132+ func outputResult (p * print.Printer , outputFormat , projectLabel string , instances []redis.Instance ) error {
134133 switch outputFormat {
135134 case print .JSONOutputFormat :
136135 details , err := json .MarshalIndent (instances , "" , " " )
@@ -149,6 +148,11 @@ func outputResult(p *print.Printer, outputFormat string, instances []redis.Insta
149148
150149 return nil
151150 default :
151+ if len (instances ) == 0 {
152+ p .Outputf ("No instances found for project %q\n " , projectLabel )
153+ return nil
154+ }
155+
152156 table := tables .NewTable ()
153157 table .SetHeader ("ID" , "NAME" , "LAST OPERATION TYPE" , "LAST OPERATION STATE" )
154158 for i := range instances {
0 commit comments