@@ -177,25 +177,23 @@ private void ParseTargetPath(Arguments arguments, string? name, IReadOnlyList<st
177
177
var couldNotParseMessage = $ "Could not parse command line parameter '{ name } '.";
178
178
179
179
// 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 )
181
182
{
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 ( ) )
191
184
{
192
185
arguments . TargetPath = name ;
193
186
return ;
194
187
}
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 ;
197
193
}
198
194
195
+ couldNotParseMessage += " If it is the target path, make sure it exists." ;
196
+
199
197
throw new WarningException ( couldNotParseMessage ) ;
200
198
}
201
199
@@ -289,13 +287,9 @@ private static bool ParseSwitches(Arguments arguments, string? name, IReadOnlyLi
289
287
return true ;
290
288
}
291
289
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 ;
299
293
}
300
294
301
295
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
357
351
return true ;
358
352
}
359
353
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 ;
368
358
}
369
359
370
360
private static void ParseShowVariable ( Arguments arguments , string ? value , string ? name )
@@ -379,7 +369,7 @@ private static void ParseShowVariable(Arguments arguments, string? value, string
379
369
if ( versionVariable == null )
380
370
{
381
371
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 } '" ) ) ;
383
373
throw new WarningException ( message ) ;
384
374
}
385
375
@@ -562,14 +552,14 @@ private static void EnsureArgumentValueCount(IReadOnlyList<string>? values)
562
552
}
563
553
}
564
554
565
- private static NameValueCollection CollectSwitchesAndValuesFromArguments ( IList < string > namedArguments , out bool firstArgumentIsSwitch )
555
+ private static NameValueCollection CollectSwitchesAndValuesFromArguments ( string [ ] namedArguments , out bool firstArgumentIsSwitch )
566
556
{
567
557
firstArgumentIsSwitch = true ;
568
558
var switchesAndValues = new NameValueCollection ( ) ;
569
559
string ? currentKey = null ;
570
560
var argumentRequiresValue = false ;
571
561
572
- for ( var i = 0 ; i < namedArguments . Count ; ++ i )
562
+ for ( var i = 0 ; i < namedArguments . Length ; ++ i )
573
563
{
574
564
var arg = namedArguments [ i ] ;
575
565
0 commit comments