Skip to content

Commit d05f9f9

Browse files
author
Kapil Borle
committed
Add argument completer for settings parameter
1 parent 84dd808 commit d05f9f9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Engine/PSScriptAnalyzer.psm1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ else
1818
{
1919
if ($PSVersionTable.PSVersion -lt [Version]'5.0') {
2020
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'PSv3'
21-
}
21+
}
2222
}
2323

2424
$binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll'
@@ -27,4 +27,14 @@ $binaryModule = Import-Module -Name $binaryModulePath -PassThru
2727
# When the module is unloaded, remove the nested binary module that was loaded with it
2828
$PSModule.OnRemove = {
2929
Remove-Module -ModuleInfo $binaryModule
30+
}
31+
32+
if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore)
33+
{
34+
Register-ArgumentCompleter -CommandName 'Invoke-ScriptAnalyzer' -ParameterName 'Settings' -ScriptBlock {
35+
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParmeter)
36+
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper]::GetBuiltinSettingPresets() | `
37+
Where-Object {$_ -like "$wordToComplete*"} | `
38+
ForEach-Object { New-Object System.Management.Automation.CompletionResult $_ }
39+
}
3040
}

0 commit comments

Comments
 (0)