detached 486766f

fix(cli): remove duplicate error outputs and improve error handling

- Remove styled error prints in push/rollback commands (Cobra handles errors)
- Add domain validation to Restart method to avoid bad requests
- Improve rollback deploy error handling to accurately reflect revert status

Changes match the pattern used in restart.go for consistency.
commit
486766f3853925b1c5783fc333232d942d345aa0
author
brice · · 2026-02-02 18:29 UTC
parent
89e85a9
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +4 -2
M internal/adapters/in/cli/push.go +0 -1
@@ -58,7 +58,6 @@ Examples:
5858 func runPush(ctx context.Context, pushDomain, tag string, build bool, platform string, buildArgs []string, noDeploy bool, noConfirm bool) error {
5959 client, isRemote := GetRemoteClient()
6060 if !isRemote {
61- fmt.Println(styles.RenderError("push command requires --remote flag or GORDON_REMOTE env var"))
6261 return fmt.Errorf("push requires remote mode")
6362 }
6463
@@ -58,7 +58,6 @@ Examples:
58 func runPush(ctx context.Context, pushDomain, tag string, build bool, platform string, buildArgs []string, noDeploy bool, noConfirm bool) error {58 func runPush(ctx context.Context, pushDomain, tag string, build bool, platform string, buildArgs []string, noDeploy bool, noConfirm bool) error {
59 client, isRemote := GetRemoteClient()59 client, isRemote := GetRemoteClient()
60 if !isRemote {60 if !isRemote {
61- fmt.Println(styles.RenderError("push command requires --remote flag or GORDON_REMOTE env var"))
62 return fmt.Errorf("push requires remote mode")61 return fmt.Errorf("push requires remote mode")
63 }62 }
64 63
M internal/adapters/in/cli/remote/client.go +3 -0
@@ -434,6 +434,9 @@ type RestartResult struct {
434434
435435 // Restart triggers a container restart for the specified domain.
436436 func (c *Client) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*RestartResult, error) {
437+ if restartDomain == "" {
438+ return nil, fmt.Errorf("domain cannot be empty")
439+ }
437440 path := "/restart/" + url.PathEscape(restartDomain)
438441 if withAttachments {
439442 path += "?attachments=true"
@@ -434,6 +434,9 @@ type RestartResult struct {
434 434
435 // Restart triggers a container restart for the specified domain.435 // Restart triggers a container restart for the specified domain.
436 func (c *Client) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*RestartResult, error) {436 func (c *Client) Restart(ctx context.Context, restartDomain string, withAttachments bool) (*RestartResult, error) {
437+ if restartDomain == "" {
438+ return nil, fmt.Errorf("domain cannot be empty")
439+ }
437 path := "/restart/" + url.PathEscape(restartDomain)440 path := "/restart/" + url.PathEscape(restartDomain)
438 if withAttachments {441 if withAttachments {
439 path += "?attachments=true"442 path += "?attachments=true"
M internal/adapters/in/cli/rollback.go +1 -1
@@ -42,7 +42,6 @@ Examples:
4242 func runRollback(ctx context.Context, rollbackDomain, targetTag string) error {
4343 client, isRemote := GetRemoteClient()
4444 if !isRemote {
45- fmt.Println(styles.RenderError("rollback command requires --remote flag or GORDON_REMOTE env var"))
4645 return fmt.Errorf("rollback requires remote mode")
4746 }
4847
@@ -172,6 +171,7 @@ func deploySelectedTag(ctx context.Context, client *remote.Client, route *domain
172171 route.Image = oldImage
173172 if revertErr := client.UpdateRoute(ctx, *route); revertErr != nil {
174173 fmt.Fprintf(os.Stderr, "WARNING: deploy failed and could not revert route: %v\n", revertErr)
174+ return fmt.Errorf("failed to deploy; revert failed: %v; deploy error: %w", revertErr, err)
175175 }
176176 return fmt.Errorf("failed to deploy (route reverted): %w", err)
177177 }
@@ -42,7 +42,6 @@ Examples:
42 func runRollback(ctx context.Context, rollbackDomain, targetTag string) error {42 func runRollback(ctx context.Context, rollbackDomain, targetTag string) error {
43 client, isRemote := GetRemoteClient()43 client, isRemote := GetRemoteClient()
44 if !isRemote {44 if !isRemote {
45- fmt.Println(styles.RenderError("rollback command requires --remote flag or GORDON_REMOTE env var"))
46 return fmt.Errorf("rollback requires remote mode")45 return fmt.Errorf("rollback requires remote mode")
47 }46 }
48 47
@@ -172,6 +171,7 @@ func deploySelectedTag(ctx context.Context, client *remote.Client, route *domain
172 route.Image = oldImage171 route.Image = oldImage
173 if revertErr := client.UpdateRoute(ctx, *route); revertErr != nil {172 if revertErr := client.UpdateRoute(ctx, *route); revertErr != nil {
174 fmt.Fprintf(os.Stderr, "WARNING: deploy failed and could not revert route: %v\n", revertErr)173 fmt.Fprintf(os.Stderr, "WARNING: deploy failed and could not revert route: %v\n", revertErr)
174+ return fmt.Errorf("failed to deploy; revert failed: %v; deploy error: %w", revertErr, err)
175 }175 }
176 return fmt.Errorf("failed to deploy (route reverted): %w", err)176 return fmt.Errorf("failed to deploy (route reverted): %w", err)
177 }177 }

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