in Sources/swift-format/Subcommands/LintFormatOptions.swift [78:100]
mutating func validate() throws {
if recursive && paths.isEmpty {
throw ValidationError("'--recursive' is only valid when formatting or linting files")
}
if assumeFilename != nil && !paths.isEmpty {
throw ValidationError("'--assume-filename' is only valid when reading from stdin")
}
if !paths.isEmpty && !recursive {
for path in paths {
var isDir: ObjCBool = false
if FileManager.default.fileExists(atPath: path, isDirectory: &isDir), isDir.boolValue {
throw ValidationError(
"""
'\(path)' is a path to a directory, not a Swift source file.
Use the '--recursive' option to handle directories.
"""
)
}
}
}
}