mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2025-05-18 06:01:56 +02:00
Extract promptForDeletion
This commit is contained in:
parent
1a9e17de10
commit
c6f4c8bd89
30
main.go
30
main.go
@ -11,7 +11,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -158,34 +157,7 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print("\033[H\033[2J")
|
promptForDeletion(reader, duplicateFiles)
|
||||||
for i, file := range duplicateFiles {
|
|
||||||
fmt.Println(i+1, file)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Which file to keep? ")
|
|
||||||
input, err := reader.ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Invalid input")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
input = strings.TrimRight(input, "\n\r")
|
|
||||||
intInput, err := strconv.Atoi(input)
|
|
||||||
if err != nil || intInput > len(duplicateFiles) || intInput < 1 {
|
|
||||||
fmt.Println("Invalid input")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, file := range duplicateFiles {
|
|
||||||
if i+1 == intInput {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if *force {
|
|
||||||
remove(file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
countInstances := 0
|
countInstances := 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user