2023-08-11 13:34:54 +02:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"velvettear/dedupe/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// exported function(s)
|
|
|
|
func Initialize() {
|
|
|
|
if len(os.Args) < 3 {
|
|
|
|
log.Fatal("error: missing arguments")
|
|
|
|
}
|
2023-08-15 14:51:54 +02:00
|
|
|
for index, arg := range os.Args {
|
2023-08-11 13:34:54 +02:00
|
|
|
arg = strings.ToLower(arg)
|
|
|
|
switch arg {
|
2023-08-15 14:51:54 +02:00
|
|
|
case "-m":
|
|
|
|
fallthrough
|
|
|
|
case "--move":
|
|
|
|
moveDirectoryIndex := index + 1
|
|
|
|
if moveDirectoryIndex >= len(os.Args) {
|
|
|
|
log.Fatal("no move directory given")
|
|
|
|
}
|
|
|
|
setMoveDirectory(os.Args[index+1])
|
2023-08-11 13:34:54 +02:00
|
|
|
case "-d":
|
|
|
|
fallthrough
|
|
|
|
case "--delete":
|
|
|
|
setDelete(true)
|
|
|
|
case "-v":
|
|
|
|
fallthrough
|
|
|
|
case "--verbose":
|
|
|
|
setVerbose(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setSourceDirectory(os.Args[1])
|
|
|
|
setComparisonDirectory(os.Args[2])
|
|
|
|
stats, error := os.Stat(SourceDirectory)
|
|
|
|
if os.IsNotExist(error) {
|
|
|
|
log.Fatal("given source directory does not exist", SourceDirectory)
|
|
|
|
}
|
|
|
|
if !stats.IsDir() {
|
|
|
|
log.Fatal("given source directory is not a directory", SourceDirectory)
|
|
|
|
}
|
|
|
|
stats, error = os.Stat(ComparisonDirectory)
|
|
|
|
if os.IsNotExist(error) {
|
|
|
|
log.Fatal("given comparison directory does not exist", ComparisonDirectory)
|
|
|
|
}
|
|
|
|
if !stats.IsDir() {
|
|
|
|
log.Fatal("given comparison directory is not a directory", ComparisonDirectory)
|
|
|
|
}
|
|
|
|
}
|