From e2855d378b1b13fe68b5dddfab3eabde451db27f Mon Sep 17 00:00:00 2001 From: James Ruskin Date: Fri, 14 Jun 2024 09:16:52 +0100 Subject: [PATCH] (maint) Adds Argument Completers To Update_All Script QOL improvement: being able to tab complete packages in the arguments for the update_all script for use when developing or testing packages. Name tab completes from the list of existing packages, ForcedPackages tab completes from existing packages _prioritising those already in Name_. --- update_all.ps1 | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/update_all.ps1 b/update_all.ps1 index 2e8d763de01..047de8bc785 100644 --- a/update_all.ps1 +++ b/update_all.ps1 @@ -1,6 +1,41 @@ # AU Packages Template: https://github.com/majkinetor/au-packages-template +[CmdletBinding()] +param( + # Specific packages to update + [ArgumentCompleter({ + param($CommandName, $ParameterName, $WordToComplete, $CommandAst, $FakeBoundParameters) + $Directory = if ($FakeBoundParameters['Root']) { + $FakeBoundParameters['Root'] + } else { + "$PSScriptRoot\automatic" + } + (Get-ChildItem $Directory -Directory).Name.Where{ + $_ -like "*$WordToComplete*" -and + $_ -notin $FakeBoundParameters['Name'] + } + })] + [string[]]$Name, + + # Packages to update regardless of the state of the upstream repository + [ArgumentCompleter({ + param($CommandName, $ParameterName, $WordToComplete, $CommandAst, $FakeBoundParameters) + $Directory = if ($FakeBoundParameters['Root']) { + $FakeBoundParameters['Root'] + } else { + "$PSScriptRoot\automatic" + } -param([string[]] $Name, [string] $ForcedPackages, [string] $Root = "$PSScriptRoot\automatic") + (Get-ChildItem $Directory -Directory).Name.Where{ + $_ -like "*$WordToComplete*" + } | Group-Object { + $_ -in $FakeBoundParameters['Name'] + } | Sort-Object | Select-Object -ExpandProperty Group + })] + [string]$ForcedPackages, + + # The directory to update packages in + [string]$Root = "$PSScriptRoot\automatic" +) if (Test-Path $PSScriptRoot/update_vars.ps1) { . $PSScriptRoot/update_vars.ps1