detached 82775f1

fix: extract printPreviewFlags to reduce waitForPreview complexity

commit
82775f18109bce98892771445697b5117559e30c
author
brice · · 2026-03-18 20:42 UTC
committer
brice · · 2026-03-18 18:19 UTC
parent
abad6c0
signature
unsigned
1 file · +8 -3
M internal/adapters/in/cli/preview.go +8 -3
@@ -275,8 +275,7 @@ func buildAndPushPreview(ctx context.Context, out io.Writer, previewRef, preview
275275 return nil
276276 }
277277
278-func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData bool) error {
279- // Print TTL/no-data info upfront
278+func printPreviewFlags(out io.Writer, ttl string, noData bool) error {
280279 if ttl != "" {
281280 if err := cliWritef(out, "Requested TTL: %s (server config controls actual TTL)\n", ttl); err != nil {
282281 return err
@@ -287,6 +286,13 @@ func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData
287286 return err
288287 }
289288 }
289+ return nil
290+}
291+
292+func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData bool) error {
293+ if err := printPreviewFlags(out, ttl, noData); err != nil {
294+ return err
295+ }
290296
291297 client, isRemote := GetRemoteClient()
292298 if !isRemote {
@@ -297,7 +303,6 @@ func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData
297303 return err
298304 }
299305
300- // Poll every 2s for up to 3 minutes
301306 ticker := time.NewTicker(2 * time.Second)
302307 defer ticker.Stop()
303308 timeout := time.After(3 * time.Minute)
@@ -275,8 +275,7 @@ func buildAndPushPreview(ctx context.Context, out io.Writer, previewRef, preview
275 return nil275 return nil
276 }276 }
277 277
278-func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData bool) error {278+func printPreviewFlags(out io.Writer, ttl string, noData bool) error {
279- // Print TTL/no-data info upfront
280 if ttl != "" {279 if ttl != "" {
281 if err := cliWritef(out, "Requested TTL: %s (server config controls actual TTL)\n", ttl); err != nil {280 if err := cliWritef(out, "Requested TTL: %s (server config controls actual TTL)\n", ttl); err != nil {
282 return err281 return err
@@ -287,6 +286,13 @@ func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData
287 return err286 return err
288 }287 }
289 }288 }
289+ return nil
290+}
291+
292+func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData bool) error {
293+ if err := printPreviewFlags(out, ttl, noData); err != nil {
294+ return err
295+ }
290 296
291 client, isRemote := GetRemoteClient()297 client, isRemote := GetRemoteClient()
292 if !isRemote {298 if !isRemote {
@@ -297,7 +303,6 @@ func waitForPreview(ctx context.Context, out io.Writer, name, ttl string, noData
297 return err303 return err
298 }304 }
299 305
300- // Poll every 2s for up to 3 minutes
301 ticker := time.NewTicker(2 * time.Second)306 ticker := time.NewTicker(2 * time.Second)
302 defer ticker.Stop()307 defer ticker.Stop()
303 timeout := time.After(3 * time.Minute)308 timeout := time.After(3 * time.Minute)

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