File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Sources/swift-format/Subcommands Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,15 @@ extension SwiftFormatCommand {
3636 var performanceMeasurementOptions : PerformanceMeasurementsOptions
3737
3838 func validate( ) throws {
39- if inPlace && formatOptions. paths. isEmpty {
40- throw ValidationError ( " '--in-place' is only valid when formatting files " )
39+ if formatOptions. paths. isEmpty, formatOptions. assumeFilename == nil {
40+ throw ValidationError (
41+ """
42+ No input files specified. Use one of the following:
43+ - Provide the path to a directory along with the '--recursive' option to format all Swift files within it.
44+ - Provide the path to a specific Swift source code file.
45+ And use '--in-place' to overwrite files in-place.
46+ """
47+ )
4148 }
4249 }
4350
Original file line number Diff line number Diff line change @@ -32,6 +32,18 @@ extension SwiftFormatCommand {
3232 @OptionGroup ( visibility: . hidden)
3333 var performanceMeasurementOptions : PerformanceMeasurementsOptions
3434
35+ func validate( ) throws {
36+ if lintOptions. paths. isEmpty, lintOptions. assumeFilename == nil {
37+ throw ValidationError (
38+ """
39+ No input files specified. Use one of the following:
40+ - Provide the path to a directory along with the '--recursive' option to lint all Swift files within it.
41+ - Provide the path to a specific Swift source code file.
42+ """
43+ )
44+ }
45+ }
46+
3547 func run( ) throws {
3648 try performanceMeasurementOptions. printingInstructionCountIfRequested {
3749 let frontend = LintFrontend ( lintFormatOptions: lintOptions)
You can’t perform that action at this time.
0 commit comments