@@ -81,21 +81,18 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8181
8282 // Call API
8383 request := buildRequest (ctx , model , apiClient )
84-
8584 response , err := request .Execute ()
8685 if err != nil {
8786 return fmt .Errorf ("list images: %w" , err )
8887 }
88+ items := response .GetItems ()
8989
90- if items := response .GetItems (); len (items ) == 0 {
91- params .Printer .Info ("No images found for project %q" , projectLabel )
92- } else {
93- if model .Limit != nil && len (items ) > int (* model .Limit ) {
94- items = (items )[:* model .Limit ]
95- }
96- if err := outputResult (params .Printer , model .OutputFormat , items ); err != nil {
97- return fmt .Errorf ("output images: %w" , err )
98- }
90+ // Truncate output
91+ if model .Limit != nil && len (items ) > int (* model .Limit ) {
92+ items = (items )[:* model .Limit ]
93+ }
94+ if err := outputResult (params .Printer , model .OutputFormat , projectLabel , items ); err != nil {
95+ return fmt .Errorf ("output images: %w" , err )
9996 }
10097
10198 return nil
@@ -149,8 +146,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
149146 return request
150147}
151148
152- func outputResult (p * print.Printer , outputFormat string , items []iaas.Image ) error {
149+ func outputResult (p * print.Printer , outputFormat , projectLabel string , items []iaas.Image ) error {
153150 return p .OutputResult (outputFormat , items , func () error {
151+ if len (items ) == 0 {
152+ p .Outputf ("No images found for project %q\n " , projectLabel )
153+ return nil
154+ }
154155 table := tables .NewTable ()
155156 table .SetHeader ("ID" , "NAME" , "OS" , "ARCHITECTURE" , "DISTRIBUTION" , "VERSION" , "SCOPE" , "OWNER" , "LABELS" )
156157 for i := range items {
0 commit comments