Functions such as
public static func pointers(forDirectory directory: String,
searchType type: SearchTypes,
recursive: Bool = false,
printOutput: Bool = false,
printVerboseOutput: Bool = false) throws -> [(filename: String, filePath: String, pointer: LFSPointer)]
, and
public func write(toFile file: String, shouldAppend: Bool = false, printOutput: Bool = false, printVerboseOutput: Bool = false) throws
, take the parameters printOutput: Bool = false, printVerboseOutput: Bool = false
. This creates code like this (taken from LFSPointer.pointer(...)
):
if printOutput && printVerboseOutput {
print("Converting \"\(file.name)\" to pointer...\n")
print("git lfs pointer --file=\(file.name)".blue)
} else if printOutput {
print("Converting \"\(file.name)\" to pointer...\n")
}
.
Let’s instead use code like this:
public func write(toFile file: String, shouldAppend: Bool = false, progressClosure: (File, RunStatus) -> Void) throws {
let file = try File(path: file)
...
progressClosure(file, .writing)
...
}
// Generate pointer.
let pointer = LFSPointer.pointer(...)
pointer.write(toFile: "/full/path/to/foo.txt") { file, status in
switch status {
case .writing:
print("Overwriting file \"\(file.name)\" with pointer...")
}
}
Todo: