Add sfdupes dwim: scan / then print duplicate trees (closes #154)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user