@@ -14,8 +14,7 @@ $binaryModuleRoot = $PSModuleRoot
1414if (($PSVersionTable.Keys -contains " PSEdition" ) -and ($PSVersionTable.PSEdition -ne ' Desktop' )) {
1515 $binaryModuleRoot = Join-Path - Path $PSModuleRoot - ChildPath ' coreclr'
1616}
17- else
18- {
17+ else {
1918 if ($PSVersionTable.PSVersion -lt [Version ]' 5.0' ) {
2019 $binaryModuleRoot = Join-Path - Path $PSModuleRoot - ChildPath ' PSv3'
2120 }
@@ -29,18 +28,23 @@ $PSModule.OnRemove = {
2928 Remove-Module - ModuleInfo $binaryModule
3029}
3130
32- if (Get-Command Register-ArgumentCompleter - ErrorAction Ignore)
33- {
34- Register-ArgumentCompleter - CommandName ' Invoke-ScriptAnalyzer' - ParameterName ' Settings' - ScriptBlock {
31+ if (Get-Command Register-ArgumentCompleter - ErrorAction Ignore) {
32+ $settingPresetCompleter = {
3533 param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParmeter )
3634
3735 [Microsoft.Windows.PowerShell.ScriptAnalyzer.Settings ]::GetSettingPresets() | `
3836 Where-Object {$_ -like " $wordToComplete *" } | `
3937 ForEach-Object { New-Object System.Management.Automation.CompletionResult $_ }
4038 }
4139
42- Function RuleNameCompleter
43- {
40+ @ (' Invoke-ScriptAnalyzer' , ' Invoke-Formatter' ) | ForEach-Object {
41+ Register-ArgumentCompleter - CommandName $_ `
42+ - ParameterName ' Settings' `
43+ - ScriptBlock $settingPresetCompleter
44+
45+ }
46+
47+ Function RuleNameCompleter {
4448 param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParmeter )
4549
4650 Get-ScriptAnalyzerRule * $wordToComplete * | `
@@ -50,4 +54,4 @@ if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)
5054 Register-ArgumentCompleter - CommandName ' Invoke-ScriptAnalyzer' - ParameterName ' IncludeRule' - ScriptBlock $Function: RuleNameCompleter
5155 Register-ArgumentCompleter - CommandName ' Invoke-ScriptAnalyzer' - ParameterName ' ExcludeRule' - ScriptBlock $Function: RuleNameCompleter
5256 Register-ArgumentCompleter - CommandName ' Get-ScriptAnalyzerRule' - ParameterName ' Name' - ScriptBlock $Function: RuleNameCompleter
53- }
57+ }
0 commit comments