@@ -485,8 +485,11 @@ private void PairPlaceholdersForCLICode(ResponseData data)
485
485
{
486
486
if ( ! cmds . TryGetValue ( script , out command ) )
487
487
{
488
- int firstParamIndex = script . IndexOf ( "--" ) ;
489
- command = script . AsSpan ( 0 , firstParamIndex ) . Trim ( ) . ToString ( ) ;
488
+ // The generated command may contain both long (--xxx) and short (-x) flag forms for its parameters.
489
+ int firstParamIndex = script . IndexOf ( " -" ) ;
490
+ command = firstParamIndex is - 1
491
+ ? script . Trim ( )
492
+ : script . AsSpan ( 0 , firstParamIndex ) . Trim ( ) . ToString ( ) ;
490
493
cmds . Add ( script , command ) ;
491
494
}
492
495
@@ -502,12 +505,8 @@ private void PairPlaceholdersForCLICode(ResponseData data)
502
505
argIndex -- ;
503
506
}
504
507
505
- // The generated AzCLI command may contain both long (--xxx) and short (-x) flag forms
506
- // for its parameters. So we need to properly handle it when looking for the parameter
507
- // right before the placeholder value.
508
- int paramIndex = 1 + Math . Max (
509
- script . LastIndexOf ( " --" , argIndex ) ,
510
- script . LastIndexOf ( " -" , argIndex ) ) ;
508
+ // The parameter for this argument may use either long (--xxx) or short (-x) flag forms.
509
+ int paramIndex = script . LastIndexOf ( " -" , argIndex ) ;
511
510
parameter = script . AsSpan ( paramIndex , argIndex - paramIndex ) . Trim ( ) . ToString ( ) ;
512
511
513
512
placeholderFound = true ;
0 commit comments