From bdc86bbdb92e0cc93c6cd9a68f93033f35af9599 Mon Sep 17 00:00:00 2001 From: Luca Di Maio Date: Sat, 20 Jun 2026 19:59:33 +0200 Subject: [PATCH] fix(rm): print 'Cannot find container' for unknown explicit names Signed-off-by: Luca Di Maio --- pkg/commands/rm.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/commands/rm.go b/pkg/commands/rm.go index fedfbe15..c70ca78f 100644 --- a/pkg/commands/rm.go +++ b/pkg/commands/rm.go @@ -68,6 +68,22 @@ func (c *RmCommand) Execute(ctx context.Context, options RmOptions) (*RmResult, distroboxesToRemove := getContainersToRemove(listResult.Containers, options.ContainerNames, options.All) + // Mirror shell distrobox-rm:353-356: for each explicit name the user + // typed that we couldn't resolve, print a "Cannot find container X." so + // typos surface instead of silently no-op'ing. + if !options.All && len(options.ContainerNames) > 0 { + found := make(map[string]bool, len(distroboxesToRemove)) + for _, d := range distroboxesToRemove { + found[d.Name] = true + } + for _, name := range options.ContainerNames { + if !found[name] { + //nolint:forbidigo // waiting for the logger implementation + fmt.Fprintf(os.Stderr, "Cannot find container %s.\n", name) + } + } + } + // Single top-level confirmation, matching the shell (distrobox-rm:413-419): // default "yes", skipped under --force/--yes; a bare Enter proceeds. if !options.Force && !options.NoTTY && len(distroboxesToRemove) > 0 {