@@ -68,22 +68,21 @@ func NewListCmd(p *params.CmdParams) *cobra.Command {
6868 return fmt.Errorf("list Intake Runners: %w", err)
6969 }
7070 runners := resp.GetIntakeRunners()
71- if len(runners) == 0 {
72- projectLabel, err := projectname.GetProjectName(ctx, p.Printer, p.CliVersion, cmd)
73- if err != nil {
74- p.Printer.Debug(print.ErrorLevel, "get project name: %v", err)
75- projectLabel = model.ProjectId
76- }
77- p.Printer.Outputf("No Intake Runners found for project %q\n", projectLabel)
78- return nil
79- }
8071
8172 // Truncate output
8273 if model.Limit != nil && len(runners) > int(*model.Limit) {
8374 runners = runners[:*model.Limit]
8475 }
8576
86- return outputResult(p.Printer, model.OutputFormat, runners)
77+ projectLabel := model.ProjectId
78+ if len(runners) == 0 {
79+ projectLabel, err = projectname.GetProjectName(ctx, p.Printer, p.CliVersion, cmd)
80+ if err != nil {
81+ p.Printer.Debug(print.ErrorLevel, "get project name: %v", err)
82+ }
83+ }
84+
85+ return outputResult(p.Printer, model.OutputFormat, projectLabel, runners)
8786 },
8887 }
8988 configureFlags(cmd)
@@ -137,7 +136,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *intake.APIC
137136}
138137
139138// outputResult formats the API response and prints it to the console
140- func outputResult(p *print.Printer, outputFormat string, runners []intake.IntakeRunnerResponse) error {
139+ func outputResult(p *print.Printer, outputFormat, projectLabel string, runners []intake.IntakeRunnerResponse) error {
141140 switch outputFormat {
142141 case print.JSONOutputFormat:
143142 details, err := json.MarshalIndent(runners, "", " ")
@@ -156,6 +155,11 @@ func outputResult(p *print.Printer, outputFormat string, runners []intake.Intake
156155 return nil
157156
158157 default:
158+ if len(runners) == 0 {
159+ p.Outputf("No intake runners found for project %q\n", projectLabel)
160+ return nil
161+ }
162+
159163 table := tables.NewTable()
160164
161165 table.SetHeader("ID", "NAME")
0 commit comments