Skip to content

Commit b746cb0

Browse files
🩹 [Patch]: Update argument completer to support Get-Font (#36)
## Description This pull request includes changes to the PowerShell scripts for font management. The most important changes involve the consolidation of argument completers and the removal of redundant code. Consolidation of argument completers: * [`src/functions/completers.ps1`](diffhunk://#diff-d85ead11500a80fca764d18c8480b383cdd0ae75862f268d0d4b4b997b27674bR1-R9): Added a new argument completer for the `Uninstall-Font` and `Get-Font` commands to handle the `Name` parameter. This script block checks the `Scope` parameter and filters font names based on the user's input. Removal of redundant code: * [`src/functions/public/Uninstall-Font.ps1`](diffhunk://#diff-2bda15615bb104b972c42d08b28af0a1692cbb5ec229ae212fc5959feab71f49L136-L145): Removed the previously defined argument completer for the `Uninstall-Font` command, as it has been consolidated into the new script block in `completers.ps1`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
1 parent 4842af1 commit b746cb0

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

src/functions/completers.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Register-ArgumentCompleter -CommandName Uninstall-Font, Get-Font -ParameterName Name -ScriptBlock {
2+
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
3+
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters
4+
if ([string]::IsNullOrEmpty($fakeBoundParameters['Scope'])) {
5+
Get-Font -Scope 'CurrentUser' | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name
6+
} else {
7+
Get-Font -Scope $fakeBoundParameters['Scope'] | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name
8+
}
9+
}

src/functions/public/Uninstall-Font.ps1

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,3 @@ Please run the command again with elevated rights (Run as Administrator) or prov
133133
Write-Verbose "[$functionName] - Done"
134134
}
135135
}
136-
137-
Register-ArgumentCompleter -CommandName Uninstall-Font -ParameterName Name -ScriptBlock {
138-
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
139-
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters
140-
if ([string]::IsNullOrEmpty($fakeBoundParameters['Scope'])) {
141-
Get-Font -Scope 'CurrentUser' | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name
142-
} else {
143-
Get-Font -Scope $fakeBoundParameters['Scope'] | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name
144-
}
145-
}

0 commit comments

Comments
 (0)