diff --git a/Sources/swift-format/Frontend/Frontend.swift b/Sources/swift-format/Frontend/Frontend.swift index a3ea18a4..b0e262a9 100644 --- a/Sources/swift-format/Frontend/Frontend.swift +++ b/Sources/swift-format/Frontend/Frontend.swift @@ -97,7 +97,23 @@ class Frontend { /// Runs the linter or formatter over the inputs. final func run() { - if lintFormatOptions.paths.isEmpty { + if lintFormatOptions.paths == ["-"] { + processStandardInput() + } else if lintFormatOptions.paths.isEmpty { + diagnosticsEngine.emitWarning( + """ + Running swift-format without input paths is deprecated and will be removed in the future. + + Please update your invocation to do either of the following: + + - Pass `-` to read from stdin (e.g., `cat MyFile.swift | swift-format -`). + - Pass one or more paths to Swift source files or directories containing + Swift source files. When passing directories, make sure to include the + `--recursive` flag. + + For more information, use the `--help` option. + """ + ) processStandardInput() } else { processURLs( diff --git a/Sources/swift-format/Subcommands/LintFormatOptions.swift b/Sources/swift-format/Subcommands/LintFormatOptions.swift index 520eaf97..737de42f 100644 --- a/Sources/swift-format/Subcommands/LintFormatOptions.swift +++ b/Sources/swift-format/Subcommands/LintFormatOptions.swift @@ -108,7 +108,7 @@ struct LintFormatOptions: ParsableArguments { var experimentalFeatures: [String] = [] /// The list of paths to Swift source files that should be formatted or linted. - @Argument(help: "Zero or more input filenames.") + @Argument(help: "Zero or more input filenames. Use `-` for stdin.") var paths: [String] = [] @Flag(help: .hidden) var debugDisablePrettyPrint: Bool = false