@@ -32,10 +32,10 @@ struct LintFormatOptions: ParsableArguments {
32
32
@Option (
33
33
name: . long,
34
34
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.
36
37
""" )
37
- var offsets : [ Range < Int > ] ?
38
-
38
+ var offsets : [ Range < Int > ]
39
39
40
40
/// The filename for the source code when reading from standard input, to include in diagnostic
41
41
/// messages.
@@ -105,7 +105,7 @@ struct LintFormatOptions: ParsableArguments {
105
105
throw ValidationError ( " '--assume-filename' is only valid when reading from stdin " )
106
106
}
107
107
108
- if offsets? . isEmpty == false && paths. count > 1 {
108
+ if ! offsets. isEmpty && paths. count > 1 {
109
109
throw ValidationError ( " '--offsets' is only valid when processing a single file " )
110
110
}
111
111
@@ -125,23 +125,19 @@ struct LintFormatOptions: ParsableArguments {
125
125
}
126
126
}
127
127
128
- extension [ Range < Int > ] {
128
+ extension Range < Int > {
129
129
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
138
135
}
139
- self = ranges
140
136
}
141
137
}
142
138
143
139
#if compiler(>=6)
144
- extension [ Range < Int > ] : @retroactive ExpressibleByArgument { }
140
+ extension Range < Int > : @retroactive ExpressibleByArgument { }
145
141
#else
146
- extension [ Range < Int > ] : ExpressibleByArgument { }
142
+ extension Range < Int > : ExpressibleByArgument { }
147
143
#endif
0 commit comments