detached 5a98fda

fix: use output writer consistently in routes list commands

Route list commands now write through the provided io.Writer instead of
stdout, and the remote path returns [] for empty JSON output instead of
bypassing the --json flag.
commit
5a98fda9181c6ae81f1e81ed9f04649722c61513
author
brice · · 2026-03-14 03:00 UTC
parent
4005e23
signature
unsigned
1 file · +12 -12
M internal/adapters/in/cli/routes.go +12 -12
@@ -140,11 +140,6 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
140140 return fmt.Errorf("failed to list routes: %w", err)
141141 }
142142
143- if len(routes) == 0 {
144- fmt.Println(styles.Theme.Muted.Render("No routes configured"))
145- return nil
146- }
147-
148143 // Get health status for each route (includes container status and HTTP probe)
149144 health, _ := client.GetHealth(ctx)
150145 if health == nil {
@@ -155,6 +150,11 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
155150 return routesListJSON(out, routes, health)
156151 }
157152
153+ if len(routes) == 0 {
154+ _, _ = fmt.Fprintln(out, styles.Theme.Muted.Render("No routes configured"))
155+ return nil
156+ }
157+
158158 const imageColWidth = 35
159159 const networkColWidth = 22
160160 rows := make([][]string, 0, len(routes))
@@ -210,9 +210,9 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
210210 components.WithRows(rows),
211211 )
212212
213- fmt.Println(styles.Theme.Title.Render("Routes"))
214- fmt.Println()
215- fmt.Println(table.View())
213+ _, _ = fmt.Fprintln(out, styles.Theme.Title.Render("Routes"))
214+ _, _ = fmt.Fprintln(out)
215+ _, _ = fmt.Fprintln(out, table.View())
216216
217217 return nil
218218 }
@@ -278,7 +278,7 @@ func runRoutesListLocal(ctx context.Context, cfgPath string, jsonOut bool, out i
278278 }
279279
280280 if len(routes) == 0 {
281- fmt.Println(styles.Theme.Muted.Render("No routes configured"))
281+ _, _ = fmt.Fprintln(out, styles.Theme.Muted.Render("No routes configured"))
282282 return nil
283283 }
284284
@@ -299,9 +299,9 @@ func runRoutesListLocal(ctx context.Context, cfgPath string, jsonOut bool, out i
299299 components.WithRows(rows),
300300 )
301301
302- fmt.Println(styles.Theme.Title.Render("Routes (local)"))
303- fmt.Println()
304- fmt.Println(table.View())
302+ _, _ = fmt.Fprintln(out, styles.Theme.Title.Render("Routes (local)"))
303+ _, _ = fmt.Fprintln(out)
304+ _, _ = fmt.Fprintln(out, table.View())
305305
306306 return nil
307307 }
@@ -140,11 +140,6 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
140 return fmt.Errorf("failed to list routes: %w", err)140 return fmt.Errorf("failed to list routes: %w", err)
141 }141 }
142 142
143- if len(routes) == 0 {
144- fmt.Println(styles.Theme.Muted.Render("No routes configured"))
145- return nil
146- }
147-
148 // Get health status for each route (includes container status and HTTP probe)143 // Get health status for each route (includes container status and HTTP probe)
149 health, _ := client.GetHealth(ctx)144 health, _ := client.GetHealth(ctx)
150 if health == nil {145 if health == nil {
@@ -155,6 +150,11 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
155 return routesListJSON(out, routes, health)150 return routesListJSON(out, routes, health)
156 }151 }
157 152
153+ if len(routes) == 0 {
154+ _, _ = fmt.Fprintln(out, styles.Theme.Muted.Render("No routes configured"))
155+ return nil
156+ }
157+
158 const imageColWidth = 35158 const imageColWidth = 35
159 const networkColWidth = 22159 const networkColWidth = 22
160 rows := make([][]string, 0, len(routes))160 rows := make([][]string, 0, len(routes))
@@ -210,9 +210,9 @@ func runRoutesListRemote(ctx context.Context, client *remote.Client, jsonOut boo
210 components.WithRows(rows),210 components.WithRows(rows),
211 )211 )
212 212
213- fmt.Println(styles.Theme.Title.Render("Routes"))213+ _, _ = fmt.Fprintln(out, styles.Theme.Title.Render("Routes"))
214- fmt.Println()214+ _, _ = fmt.Fprintln(out)
215- fmt.Println(table.View())215+ _, _ = fmt.Fprintln(out, table.View())
216 216
217 return nil217 return nil
218 }218 }
@@ -278,7 +278,7 @@ func runRoutesListLocal(ctx context.Context, cfgPath string, jsonOut bool, out i
278 }278 }
279 279
280 if len(routes) == 0 {280 if len(routes) == 0 {
281- fmt.Println(styles.Theme.Muted.Render("No routes configured"))281+ _, _ = fmt.Fprintln(out, styles.Theme.Muted.Render("No routes configured"))
282 return nil282 return nil
283 }283 }
284 284
@@ -299,9 +299,9 @@ func runRoutesListLocal(ctx context.Context, cfgPath string, jsonOut bool, out i
299 components.WithRows(rows),299 components.WithRows(rows),
300 )300 )
301 301
302- fmt.Println(styles.Theme.Title.Render("Routes (local)"))302+ _, _ = fmt.Fprintln(out, styles.Theme.Title.Render("Routes (local)"))
303- fmt.Println()303+ _, _ = fmt.Fprintln(out)
304- fmt.Println(table.View())304+ _, _ = fmt.Fprintln(out, table.View())
305 305
306 return nil306 return nil
307 }307 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close