@@ -188,8 +188,8 @@ extension ErrorMessageGenerator {
188188 return unexpectedValueForOptionMessage ( origin: o, name: n, value: v)
189189 case . unexpectedExtraValues( let v) :
190190 return unexpectedExtraValuesMessage ( values: v)
191- case . duplicateExclusiveValues( previous: let previous, duplicate: let duplicate) :
192- return duplicateExclusiveValues ( previous: previous, duplicate: duplicate)
191+ case . duplicateExclusiveValues( previous: let previous, duplicate: let duplicate, originalInput : let arguments ) :
192+ return duplicateExclusiveValues ( previous: previous, duplicate: duplicate, arguments : arguments )
193193 case . noValue( forKey: let k) :
194194 return noValueMessage ( key: k)
195195 case . unableToParseValue( let o, let n, let v, forKey: let k) :
@@ -301,8 +301,23 @@ extension ErrorMessageGenerator {
301301 }
302302 }
303303
304- func duplicateExclusiveValues( previous: InputOrigin , duplicate: InputOrigin ) -> String ? {
305- return " Value at position \( duplicate) has already been set from value at position \( previous) . "
304+ func duplicateExclusiveValues( previous: InputOrigin , duplicate: InputOrigin , arguments: [ String ] ) -> String ? {
305+ func elementString( _ origin: InputOrigin , _ arguments: [ String ] ) -> String ? {
306+ guard case . argumentIndex( let split) = origin. elements. first else { return nil }
307+ var argument = " \' \( arguments [ split. inputIndex. rawValue] ) \' "
308+ if case let . sub( offsetIndex) = split. subIndex {
309+ let stringIndex = argument. index ( argument. startIndex, offsetBy: offsetIndex+ 2 )
310+ argument = " \' \( argument [ stringIndex] ) \' in \( argument) "
311+ }
312+ return " flag \( argument) "
313+ }
314+
315+ // Note that the RHS of these coalescing operators cannot be reached at this time.
316+ let dupeString = elementString ( duplicate, arguments) ?? " position \( duplicate) "
317+ let origString = elementString ( previous, arguments) ?? " position \( previous) "
318+
319+ //TODO: review this message once environment values are supported.
320+ return " Value to be set with \( dupeString) had already been set with \( origString) "
306321 }
307322
308323 func noValueMessage( key: InputKey ) -> String ? {
0 commit comments