import FoldFormat import Folding import Foundation // foldlint ... // // Prints each defect as `: `, one per line, and exits 1 when there is one. A file // that validates has its steps read and its layer motion checked. let paths = Array(CommandLine.arguments.dropFirst()) guard !paths.isEmpty else { FileHandle.standardError.write(Data("usage: foldlint ...\n".utf8)) exit(2) } var clean = true for path in paths { func report(_ defect: Any) { print("\(path): \(defect)") clean = false } do { let file = try FoldFile(contentsOf: URL(fileURLWithPath: path)) let defects = validate(file) defects.forEach(report) guard defects.isEmpty else { continue } _ = try readSteps(file) layerMotionDefects(file).forEach(report) } catch { report(error) } } exit(clean ? 0 : 1)