fix(rm): print 'Cannot find container' for unknown explicit names

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio committed 2026-06-25 09:07:25 +02:00
1 parent d0bc6af01b
commit bdc86bbdb9
1 file changed
+16
+16
View File
@@ -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 {