Skip to content

Commit d443f45

Browse files
committed
Gradually deprecate running swift-format without input paths; require '-' for stdin in the future
1 parent 6e64b26 commit d443f45

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/swift-format/Frontend/Frontend.swift

+16-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,22 @@ class Frontend {
9797

9898
/// Runs the linter or formatter over the inputs.
9999
final func run() {
100-
if lintFormatOptions.paths.isEmpty {
100+
if lintFormatOptions.paths == ["-"] {
101+
processStandardInput()
102+
} else if lintFormatOptions.paths.isEmpty {
103+
diagnosticsEngine.emitWarning(
104+
"""
105+
Running swift-format without input paths is deprecated and will be removed in the future.
106+
107+
Please specify one of the following:
108+
109+
- Use - to read from stdin (e.g., cat MyFile.swift | swift-format -)
110+
- Provide a directory path (e.g., swift format --recursive MyDirectory/)
111+
- Provide a specific Swift source file (e.g., swift format MyFile.swift)
112+
113+
For more information, use the --help option.
114+
"""
115+
)
101116
processStandardInput()
102117
} else {
103118
processURLs(

0 commit comments

Comments
 (0)