Files
sfdupes/dwim.go
T
sneak 34e73c1527
check / check (push) Canceled after 0s
Add sfdupes dwim: scan / then print duplicate trees (closes #154)
dwim runs what "sfdupes scan /" runs with no flags, then what
"sfdupes trees" runs, and ends with a stderr line saying that
"sfdupes trees" prints the report again. An interrupt or fatal scan
error ends it before the report, as scan ends.

Model: opus-5-5
2026-11-06 19:10:23 +00:00

32 lines
724 B
Go

package main
import (
"context"
"fmt"
"io"
"os"
"runtime"
)
// runDwim implements the dwim subcommand: it runs what "sfdupes scan
// root" runs with no flags, then what "sfdupes trees" runs, and ends
// with a line on stderr saying how to print the report again. The dwim
// command passes "/" as root. An error from the scan, an interrupt
// included, ends it before the report.
func runDwim(ctx context.Context, root string, stdout io.Writer) error {
err := runScan(ctx, []string{root}, runtime.NumCPU(), false, false)
if err != nil {
return err
}
err = runTrees(ctx, stdout)
if err != nil {
return err
}
fmt.Fprintln(os.Stderr,
`dwim: run "sfdupes trees" to print this report again`)
return nil
}