diff --git a/Sources/swift-format/Subcommands/Format.swift b/Sources/swift-format/Subcommands/Format.swift index 42c2da16..5ac3ff17 100644 --- a/Sources/swift-format/Subcommands/Format.swift +++ b/Sources/swift-format/Subcommands/Format.swift @@ -36,6 +36,16 @@ extension SwiftFormatCommand { var performanceMeasurementOptions: PerformanceMeasurementsOptions func validate() throws { + if formatOptions.paths.isEmpty && !inPlace { + throw ValidationError( + """ + No input files specified. Use one of the following: + - Provide the path to a directory along with the '--recursive' option to format all Swift files within it. + - Provide the path to a specific Swift source code file. + And use '--in-place' to overwrite files in-place. + """ + ) + } if inPlace && formatOptions.paths.isEmpty { throw ValidationError("'--in-place' is only valid when formatting files") }