diff --git a/cmd/podman/system/connection/remove.go b/cmd/podman/system/connection/remove.go index 225b1f038f..3398a7601f 100644 --- a/cmd/podman/system/connection/remove.go +++ b/cmd/podman/system/connection/remove.go @@ -1,7 +1,6 @@ package connection import ( - "errors" "slices" "github.com/containers/common/pkg/config" @@ -14,10 +13,16 @@ import ( var ( // Skip creating engines since this command will obtain connection information to said engines. rmCmd = &cobra.Command{ - Use: "remove [options] NAME", - Aliases: []string{"rm"}, - Long: `Delete named destination from podman configuration`, - Short: "Delete named destination", + Use: "remove [options] NAME", + Aliases: []string{"rm"}, + Long: `Delete named destination from podman configuration`, + Short: "Delete named destination", + Args: func(cmd *cobra.Command, args []string) error { + if rmOpts.All { + return nil + } + return cobra.ExactArgs(1)(cmd, args) + }, ValidArgsFunction: common.AutocompleteSystemConnections, RunE: rm, Example: `podman system connection remove devl @@ -60,10 +65,6 @@ func rm(cmd *cobra.Command, args []string) error { return nil } - if len(args) != 1 { - return errors.New("accepts 1 arg(s), received 0") - } - delete(cfg.Connection.Connections, args[0]) if cfg.Connection.Default == args[0] { cfg.Connection.Default = ""