@@ -77,25 +77,22 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7777 return fmt .Errorf ("list networks: %w" , err )
7878 }
7979
80- if resp .Items == nil || len (* resp .Items ) == 0 {
81- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
82- if err != nil {
83- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
84- projectLabel = model .ProjectId
85- } else if projectLabel == "" {
86- projectLabel = model .ProjectId
87- }
88- params .Printer .Info ("No networks found for project %q\n " , projectLabel )
89- return nil
80+ items := resp .GetItems ()
81+
82+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
83+ if err != nil {
84+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
85+ projectLabel = model .ProjectId
86+ } else if projectLabel == "" {
87+ projectLabel = model .ProjectId
9088 }
9189
9290 // Truncate output
93- items := * resp .Items
9491 if model .Limit != nil && len (items ) > int (* model .Limit ) {
9592 items = items [:* model .Limit ]
9693 }
9794
98- return outputResult (params .Printer , model .OutputFormat , items )
95+ return outputResult (params .Printer , model .OutputFormat , projectLabel , items )
9996 },
10097 }
10198 configureFlags (cmd )
@@ -139,8 +136,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
139136 return req
140137}
141138
142- func outputResult (p * print.Printer , outputFormat string , networks []iaas.Network ) error {
139+ func outputResult (p * print.Printer , outputFormat , projectLabel string , networks []iaas.Network ) error {
143140 return p .OutputResult (outputFormat , networks , func () error {
141+ if len (networks ) == 0 {
142+ p .Outputf ("No networks found for project %q\n " , projectLabel )
143+ return nil
144+ }
145+
144146 table := tables .NewTable ()
145147 table .SetHeader ("ID" , "NAME" , "STATUS" , "PUBLIC IP" , "PREFIXES" , "ROUTED" , "ROUTING TABLE ID" )
146148
0 commit comments