From 3fc246936bc95c2456037f734f8ef20cfc400c46 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 20 May 2025 22:21:59 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20module?= =?UTF-8?q?=20version=20requirements=20and=20fix=20documentation=20links?= =?UTF-8?q?=20for=20font=20functionsw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Get-Font.ps1 | 14 +++++++------- src/functions/public/Install-Font.ps1 | 4 ++-- src/functions/public/Uninstall-Font.ps1 | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/functions/public/Get-Font.ps1 b/src/functions/public/Get-Font.ps1 index a6c5636..7a4d53a 100644 --- a/src/functions/public/Get-Font.ps1 +++ b/src/functions/public/Get-Font.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.5' } +#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.6' } function Get-Font { <# @@ -16,7 +16,7 @@ function Get-Font { ```powershell Name Path Scope ---- ---- ----- - Arial C:\Windows\Fonts\arial.ttf CurrentUser + Arial C:\Windows\Fonts\arial.ttf CurrentUser ``` Gets all the fonts installed for the current user. @@ -28,8 +28,8 @@ function Get-Font { ```powershell Name Path Scope ---- ---- ----- - Arial C:\Windows\Fonts\arial.ttf CurrentUser - Arial Bold C:\Windows\Fonts\arialbd.ttf CurrentUser + Arial C:\Windows\Fonts\arial.ttf CurrentUser + Arial Bold C:\Windows\Fonts\arialbd.ttf CurrentUser ``` Gets all the fonts installed for the current user that start with 'Arial'. @@ -41,7 +41,7 @@ function Get-Font { ```powershell Name Path Scope ---- ---- ----- - Calibri C:\Windows\Fonts\calibri.ttf AllUsers + Calibri C:\Windows\Fonts\calibri.ttf AllUsers ``` Gets all the fonts installed for all users. @@ -53,7 +53,7 @@ function Get-Font { ```powershell Name Path Scope ---- ---- ----- - Calibri C:\Windows\Fonts\calibri.ttf AllUsers + Calibri C:\Windows\Fonts\calibri.ttf AllUsers ``` Gets the font with the name 'Calibri' for all users. @@ -69,7 +69,7 @@ function Get-Font { - Scope: The scope from which the font is retrieved. .LINK - https://psmodule.io/Font/Functions/Get-Font + https://psmodule.io/Fonts/Functions/Get-Font/ #> [Alias('Get-Fonts')] [OutputType([System.Collections.Generic.List[PSCustomObject]])] diff --git a/src/functions/public/Install-Font.ps1 b/src/functions/public/Install-Font.ps1 index efe368d..76fbd47 100644 --- a/src/functions/public/Install-Font.ps1 +++ b/src/functions/public/Install-Font.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.5' } +#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.6' } function Install-Font { <# @@ -101,7 +101,7 @@ function Install-Font { Returns messages indicating success or failure of font installation. .LINK - https://psmodule.io/Admin/Functions/Install-Font/ + https://psmodule.io/Fonts/Functions/Install-Font/ #> [Alias('Install-Fonts')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Uninstall-Font.ps1 b/src/functions/public/Uninstall-Font.ps1 index d781320..b94f607 100644 --- a/src/functions/public/Uninstall-Font.ps1 +++ b/src/functions/public/Uninstall-Font.ps1 @@ -1,4 +1,6 @@ -function Uninstall-Font { +#Requires -Modules @{ ModuleName = 'Admin'; RequiredVersion = '1.1.6' } + +function Uninstall-Font { <# .SYNOPSIS Uninstalls a font from the system. @@ -41,7 +43,7 @@ The function does not return any objects. .LINK - https://psmodule.io/Admin/Functions/Uninstall-Font/ + https://psmodule.io/Fonts/Functions/Uninstall-Font/ #> [Alias('Uninstall-Fonts')] [CmdletBinding()] From c4c806d7dd824313f209f3a0b6ac32afea341d75 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 20 May 2025 22:22:05 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20argume?= =?UTF-8?q?nt=20completer=20for=20font=20commands=20to=20improve=20scope?= =?UTF-8?q?=20handling=20and=20code=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/completers.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/functions/completers.ps1 b/src/functions/completers.ps1 index c1709a2..8e7e329 100644 --- a/src/functions/completers.ps1 +++ b/src/functions/completers.ps1 @@ -1,9 +1,12 @@ -Register-ArgumentCompleter -CommandName Uninstall-Font, Get-Font -ParameterName Name -ScriptBlock { +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 + $scope = if ([string]::IsNullOrEmpty($fakeBoundParameters['Scope'])) { + 'CurrentUser' } else { - Get-Font -Scope $fakeBoundParameters['Scope'] | Where-Object { $_.Name -like "$wordToComplete*" } | Select-Object -ExpandProperty Name + $fakeBoundParameters['Scope'] + } + (Get-Font -Scope $scope).Name | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } }