private/completions/Completers.psm1
using namespace Spectre.Console using namespace System.Management.Automation class ValidateSpectreColor : ValidateArgumentsAttribute { ValidateSpectreColor() : base() { } [void]Validate([object] $Color, [EngineIntrinsics]$EngineIntrinsics) { # Handle hex colors if ($Color -match '^#[A-Fa-f0-9]{6}$') { return } $spectreColors = [Color] | Get-Member -Static -Type Properties | Select-Object -ExpandProperty Name $result = $spectreColors -contains $Color if ($result -eq $false) { throw "'$Color' is not in the list of valid Spectre colors ['$($spectreColors -join ''', ''')']" } } } class ArgumentCompletionsSpectreColors : ArgumentCompleterAttribute { ArgumentCompletionsSpectreColors() : base({ param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $options = [Color] | Get-Member -Static -Type Properties | Select-Object -ExpandProperty Name return $options | Where-Object { $_ -like "$wordToComplete*" } }) { } } class SpectreConsoleTableBorder : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = [TableBorder] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name return $lookup } } class SpectreConsoleBoxBorder : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = [BoxBorder] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name return $lookup } } class SpectreConsoleJustify : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = [Justify].GetEnumNames() return $lookup } } class SpectreConsoleSpinner : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = [Spinner+Known] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name return $lookup } } class SpectreConsoleTreeGuide : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = [TreeGuide] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name return $lookup } } class SpectreConsoleWidth : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = 1..[console]::BufferWidth return $lookup } } class SpectreConsoleHeight : IValidateSetValuesGenerator { [String[]] GetValidValues() { $lookup = 1..[console]::BufferHeight return $lookup } } |