@@ -32,10 +32,10 @@ struct LintFormatOptions: ParsableArguments {
3232 @Option (
3333 name: . long,
3434 help: """
35- A list of comma-separated " start:end " pairs specifying UTF-8 offsets of the ranges to format.
35+ A " start:end " pair specifying UTF-8 offsets of the range to format. Multiple ranges can be
36+ formatted by specifying several --offsets arguments.
3637 """ )
37- var offsets : [ Range < Int > ] ?
38-
38+ var offsets : [ Range < Int > ]
3939
4040 /// The filename for the source code when reading from standard input, to include in diagnostic
4141 /// messages.
@@ -105,7 +105,7 @@ struct LintFormatOptions: ParsableArguments {
105105 throw ValidationError ( " '--assume-filename' is only valid when reading from stdin " )
106106 }
107107
108- if offsets? . isEmpty == false && paths. count > 1 {
108+ if ! offsets. isEmpty && paths. count > 1 {
109109 throw ValidationError ( " '--offsets' is only valid when processing a single file " )
110110 }
111111
@@ -125,23 +125,19 @@ struct LintFormatOptions: ParsableArguments {
125125 }
126126}
127127
128- extension [ Range < Int > ] {
128+ extension Range < Int > {
129129 public init ? ( argument: String ) {
130- let pairs = argument. components ( separatedBy: " , " )
131- let ranges : [ Range < Int > ] = pairs. compactMap {
132- let pair = $0. components ( separatedBy: " : " )
133- if pair. count == 2 , let start = Int ( pair [ 0 ] ) , let end = Int ( pair [ 1 ] ) , start <= end {
134- return start ..< end
135- } else {
136- return nil
137- }
130+ let pair = argument. components ( separatedBy: " : " )
131+ if pair. count == 2 , let start = Int ( pair [ 0 ] ) , let end = Int ( pair [ 1 ] ) , start <= end {
132+ self = start ..< end
133+ } else {
134+ return nil
138135 }
139- self = ranges
140136 }
141137}
142138
143139#if compiler(>=6)
144- extension [ Range < Int > ] : @retroactive ExpressibleByArgument { }
140+ extension Range < Int > : @retroactive ExpressibleByArgument { }
145141#else
146- extension [ Range < Int > ] : ExpressibleByArgument { }
142+ extension Range < Int > : ExpressibleByArgument { }
147143#endif
0 commit comments