mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
fix: return non-exit code when uc commands cancelled by not confirming prompt (fixes #354)
This commit is contained in:
@@ -175,8 +175,7 @@ func runDeploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
|
||||
return fmt.Errorf("confirm deployment: %w", err)
|
||||
}
|
||||
if !confirmed {
|
||||
fmt.Println("Cancelled. No changes were made.")
|
||||
return nil
|
||||
return cli.Cancelled("Caddy deploy cancelled. No changes were made.")
|
||||
}
|
||||
|
||||
err = progress.RunWithTitle(ctx, func(ctx context.Context) error {
|
||||
|
||||
@@ -222,8 +222,7 @@ func runDeploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
|
||||
return fmt.Errorf("confirm deployment: %w", err)
|
||||
}
|
||||
if !confirmed {
|
||||
fmt.Println("Cancelled. No changes were made.")
|
||||
return nil
|
||||
return cli.Cancelled("Deploy cancelled. No changes were made.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,8 +232,7 @@ func add(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteMachine,
|
||||
return fmt.Errorf("confirm deployment: %w", err)
|
||||
}
|
||||
if !confirmed {
|
||||
fmt.Println("Cancelled. No changes were made.")
|
||||
return nil
|
||||
return cli.Cancelled("Caddy deploy cancelled. The machine has been added to the cluster.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -2,8 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"charm.land/lipgloss/v2"
|
||||
@@ -152,5 +154,11 @@ func main() {
|
||||
volume.NewRootCommand(),
|
||||
wg.NewRootCommand(),
|
||||
)
|
||||
cobra.CheckErr(cmd.Execute())
|
||||
if err := cmd.Execute(); err != nil {
|
||||
if cancelled, ok := errors.AsType[*cli.CancelledError](err); ok {
|
||||
fmt.Fprintln(os.Stderr, cancelled.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
cobra.CheckErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,7 @@ func scale(ctx context.Context, uncli *cli.CLI, opts scaleOptions) error {
|
||||
return fmt.Errorf("confirm scaling: %w", err)
|
||||
}
|
||||
if !confirmed {
|
||||
fmt.Println("Cancelled. No changes were made.")
|
||||
return nil
|
||||
return cli.Cancelled("Scaling cancelled. No changes were made.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user