@@ -177,25 +177,23 @@ private void ParseTargetPath(Arguments arguments, string? name, IReadOnlyList<st
177177 var couldNotParseMessage = $ "Could not parse command line parameter '{ name } '.";
178178
179179 // If we've reached through all argument switches without a match, we can relatively safely assume that the first argument isn't a switch, but the target path.
180- if ( parseEnded )
180+ if ( ! parseEnded ) throw new WarningException ( couldNotParseMessage ) ;
181+ if ( name ? . StartsWith ( '/' ) == true )
181182 {
182- if ( name ? . StartsWith ( '/' ) == true )
183- {
184- if ( FileSystemHelper . Path . DirectorySeparatorChar == '/' && name . IsValidPath ( ) )
185- {
186- arguments . TargetPath = name ;
187- return ;
188- }
189- }
190- else if ( ! name . IsSwitchArgument ( ) )
183+ if ( FileSystemHelper . Path . DirectorySeparatorChar == '/' && name . IsValidPath ( ) )
191184 {
192185 arguments . TargetPath = name ;
193186 return ;
194187 }
195-
196- couldNotParseMessage += " If it is the target path, make sure it exists." ;
188+ }
189+ else if ( ! name . IsSwitchArgument ( ) )
190+ {
191+ arguments . TargetPath = name ;
192+ return ;
197193 }
198194
195+ couldNotParseMessage += " If it is the target path, make sure it exists." ;
196+
199197 throw new WarningException ( couldNotParseMessage ) ;
200198 }
201199
@@ -289,13 +287,9 @@ private static bool ParseSwitches(Arguments arguments, string? name, IReadOnlyLi
289287 return true ;
290288 }
291289
292- if ( name . IsSwitch ( "updatewixversionfile" ) )
293- {
294- arguments . UpdateWixVersionFile = true ;
295- return true ;
296- }
297-
298- return false ;
290+ if ( ! name . IsSwitch ( "updatewixversionfile" ) ) return false ;
291+ arguments . UpdateWixVersionFile = true ;
292+ return true ;
299293 }
300294
301295 private static bool ParseConfigArguments ( Arguments arguments , string ? name , IReadOnlyList < string > ? values , string ? value )
@@ -357,14 +351,10 @@ private static bool ParseRemoteArguments(Arguments arguments, string? name, IRea
357351 return true ;
358352 }
359353
360- if ( name . IsSwitch ( "b" ) )
361- {
362- EnsureArgumentValueCount ( values ) ;
363- arguments . TargetBranch = value ;
364- return true ;
365- }
366-
367- return false ;
354+ if ( ! name . IsSwitch ( "b" ) ) return false ;
355+ EnsureArgumentValueCount ( values ) ;
356+ arguments . TargetBranch = value ;
357+ return true ;
368358 }
369359
370360 private static void ParseShowVariable ( Arguments arguments , string ? value , string ? name )
@@ -379,7 +369,7 @@ private static void ParseShowVariable(Arguments arguments, string? value, string
379369 if ( versionVariable == null )
380370 {
381371 var message = $ "{ name } requires a valid version variable. Available variables are:{ FileSystemHelper . Path . NewLine } " +
382- string . Join ( ", " , availableVariables . Select ( x => string . Concat ( "'" , x , "'" ) ) ) ;
372+ string . Join ( ", " , availableVariables . Select ( x => $ "' { x } '" ) ) ;
383373 throw new WarningException ( message ) ;
384374 }
385375
@@ -562,14 +552,14 @@ private static void EnsureArgumentValueCount(IReadOnlyList<string>? values)
562552 }
563553 }
564554
565- private static NameValueCollection CollectSwitchesAndValuesFromArguments ( IList < string > namedArguments , out bool firstArgumentIsSwitch )
555+ private static NameValueCollection CollectSwitchesAndValuesFromArguments ( string [ ] namedArguments , out bool firstArgumentIsSwitch )
566556 {
567557 firstArgumentIsSwitch = true ;
568558 var switchesAndValues = new NameValueCollection ( ) ;
569559 string ? currentKey = null ;
570560 var argumentRequiresValue = false ;
571561
572- for ( var i = 0 ; i < namedArguments . Count ; ++ i )
562+ for ( var i = 0 ; i < namedArguments . Length ; ++ i )
573563 {
574564 var arg = namedArguments [ i ] ;
575565
0 commit comments