diff --git a/src/functions/completers.ps1 b/src/functions/completers.ps1 new file mode 100644 index 0000000..c1709a2 --- /dev/null +++ b/src/functions/completers.ps1 @@ -0,0 +1,9 @@ +Register-ArgumentCompleter -CommandName Uninstall-Font, Get-Font -ParameterName Name -ScriptBlock { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters + if ([string]::IsNullOrEmpty($fakeBoundParameters['Scope'])) { + Get-Font -Scope 'CurrentUser' | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name + } else { + Get-Font -Scope $fakeBoundParameters['Scope'] | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name + } +} diff --git a/src/functions/public/Uninstall-Font.ps1 b/src/functions/public/Uninstall-Font.ps1 index aac6276..5e36b04 100644 --- a/src/functions/public/Uninstall-Font.ps1 +++ b/src/functions/public/Uninstall-Font.ps1 @@ -133,13 +133,3 @@ Please run the command again with elevated rights (Run as Administrator) or prov Write-Verbose "[$functionName] - Done" } } - -Register-ArgumentCompleter -CommandName Uninstall-Font -ParameterName Name -ScriptBlock { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) - $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters - if ([string]::IsNullOrEmpty($fakeBoundParameters['Scope'])) { - Get-Font -Scope 'CurrentUser' | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name - } else { - Get-Font -Scope $fakeBoundParameters['Scope'] | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name - } -}