43 lines
967 B
Go
43 lines
967 B
Go
package settings
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"velvettear/dedupe/log"
|
|
)
|
|
|
|
// exported function(s)
|
|
func Initialize() {
|
|
if len(os.Args) < 3 {
|
|
log.Fatal("error: missing arguments")
|
|
}
|
|
for _, arg := range os.Args {
|
|
arg = strings.ToLower(arg)
|
|
switch arg {
|
|
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)
|
|
}
|
|
}
|