@@ -485,8 +485,11 @@ private void PairPlaceholdersForCLICode(ResponseData data)
485485 {
486486 if ( ! cmds . TryGetValue ( script , out command ) )
487487 {
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 ( ) ;
490493 cmds . Add ( script , command ) ;
491494 }
492495
@@ -502,12 +505,8 @@ private void PairPlaceholdersForCLICode(ResponseData data)
502505 argIndex -- ;
503506 }
504507
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 ) ;
511510 parameter = script . AsSpan ( paramIndex , argIndex - paramIndex ) . Trim ( ) . ToString ( ) ;
512511
513512 placeholderFound = true ;
0 commit comments