@@ -68,23 +68,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6868 if err != nil {
6969 return fmt .Errorf ("get PostgreSQL Flex instances: %w" , err )
7070 }
71- if len (resp .Items ) == 0 {
72- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
73- if err != nil {
74- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
75- projectLabel = model .ProjectId
76- }
77- params .Printer .Info ("No instances found for project %q\n " , projectLabel )
78- return nil
79- }
71+
8072 instances := resp .Items
8173
8274 // Truncate output
8375 if model .Limit != nil && len (instances ) > int (* model .Limit ) {
8476 instances = instances [:* model .Limit ]
8577 }
8678
87- return outputResult (params .Printer , model .OutputFormat , instances )
79+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
80+ if err != nil {
81+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
82+ projectLabel = model .ProjectId
83+ }
84+ return outputResult (params .Printer , model .OutputFormat , projectLabel , instances )
8885 },
8986 }
9087
@@ -124,8 +121,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *postgresfle
124121 return req
125122}
126123
127- func outputResult (p * print.Printer , outputFormat string , instances []postgresflex.InstanceListInstance ) error {
124+ func outputResult (p * print.Printer , outputFormat , projectLabel string , instances []postgresflex.InstanceListInstance ) error {
128125 return p .OutputResult (outputFormat , instances , func () error {
126+ if len (instances ) == 0 {
127+ p .Outputf ("No instances found for project %q\n " , projectLabel )
128+ return nil
129+ }
129130 caser := cases .Title (language .English )
130131 table := tables .NewTable ()
131132 table .SetHeader ("ID" , "NAME" , "STATUS" )
0 commit comments