No longer support old format
This commit is contained in:
32
main.go
32
main.go
@@ -20,8 +20,7 @@ const ImportantColor = BRed
|
||||
const DefaultColor = White
|
||||
const PathColor = Green
|
||||
|
||||
var DirRegex, _ = regexp.Compile(`^(.+?)[/\\]sync(?:\.ya?ml)?$`)
|
||||
var FileRegex, _ = regexp.Compile(`^sync(?:\.ya?ml)?$`)
|
||||
var FileRegex, _ = regexp.Compile(`sync\.ya?ml$`)
|
||||
var programName = os.Args[0]
|
||||
|
||||
func main() {
|
||||
@@ -65,10 +64,7 @@ func main() {
|
||||
go ReadFromStdin(instructions, status)
|
||||
|
||||
default:
|
||||
if _, err := os.Stat("sync"); err == nil {
|
||||
log.Printf("Using default sync file")
|
||||
go ReadFromFile("sync", instructions, status, true)
|
||||
} else if _, err := os.Stat("sync.yaml"); err == nil {
|
||||
if _, err := os.Stat("sync.yaml"); err == nil {
|
||||
log.Printf("Using default sync.yaml file")
|
||||
go ReadFromFile("sync.yaml", instructions, status, true)
|
||||
} else if _, err := os.Stat("sync.yml"); err == nil {
|
||||
@@ -172,7 +168,7 @@ func ReadFromFilesRecursively(input string, output chan *LinkInstruction, status
|
||||
log.Printf("Processing file: %s%s%s", PathColor, file, DefaultColor)
|
||||
|
||||
// This "has" to be done because instructions are resolved in relation to cwd
|
||||
fileDir := DirRegex.FindStringSubmatch(file)
|
||||
fileDir := FileRegex.FindStringSubmatch(file)
|
||||
if fileDir == nil {
|
||||
log.Printf("Failed to extract directory from %s%s%s", SourceColor, file, DefaultColor)
|
||||
return
|
||||
@@ -217,28 +213,6 @@ func ReadFromFile(input string, output chan *LinkInstruction, status chan error,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Handle CSV format (legacy)
|
||||
file, err := os.Open(input)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open file %s%s%s: %s%+v%s",
|
||||
SourceColor, input, DefaultColor, ErrorColor, err, DefaultColor)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
instruction, err := ParseInstruction(line, filepath.Dir(input))
|
||||
if err != nil {
|
||||
log.Printf("Error parsing line: %s'%s'%s, error: %s%+v%s",
|
||||
SourceColor, line, DefaultColor, ErrorColor, err, DefaultColor)
|
||||
continue
|
||||
}
|
||||
log.Printf("Read instruction: %s", instruction.String())
|
||||
output <- &instruction
|
||||
}
|
||||
}
|
||||
|
||||
func ReadFromArgs(output chan *LinkInstruction, status chan error) {
|
||||
|
Reference in New Issue
Block a user