@@ -14,8 +14,7 @@ $binaryModuleRoot = $PSModuleRoot
14
14
if (($PSVersionTable.Keys -contains " PSEdition" ) -and ($PSVersionTable.PSEdition -ne ' Desktop' )) {
15
15
$binaryModuleRoot = Join-Path - Path $PSModuleRoot - ChildPath ' coreclr'
16
16
}
17
- else
18
- {
17
+ else {
19
18
if ($PSVersionTable.PSVersion -lt [Version ]' 5.0' ) {
20
19
$binaryModuleRoot = Join-Path - Path $PSModuleRoot - ChildPath ' PSv3'
21
20
}
@@ -29,18 +28,23 @@ $PSModule.OnRemove = {
29
28
Remove-Module - ModuleInfo $binaryModule
30
29
}
31
30
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 = {
35
33
param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParmeter )
36
34
37
35
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Settings ]::GetSettingPresets() | `
38
36
Where-Object {$_ -like " $wordToComplete *" } | `
39
37
ForEach-Object { New-Object System.Management.Automation.CompletionResult $_ }
40
38
}
41
39
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 {
44
48
param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParmeter )
45
49
46
50
Get-ScriptAnalyzerRule * $wordToComplete * | `
@@ -50,4 +54,4 @@ if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)
50
54
Register-ArgumentCompleter - CommandName ' Invoke-ScriptAnalyzer' - ParameterName ' IncludeRule' - ScriptBlock $Function: RuleNameCompleter
51
55
Register-ArgumentCompleter - CommandName ' Invoke-ScriptAnalyzer' - ParameterName ' ExcludeRule' - ScriptBlock $Function: RuleNameCompleter
52
56
Register-ArgumentCompleter - CommandName ' Get-ScriptAnalyzerRule' - ParameterName ' Name' - ScriptBlock $Function: RuleNameCompleter
53
- }
57
+ }
0 commit comments