Skip to content

Commit

Permalink
feat: Escaping Labels by default ( Fixes #235, Fixes #247 )
Browse files Browse the repository at this point in the history
  • Loading branch information
StartAutomating committed Sep 27, 2024
2 parents c23bd08 + 007a57c commit b7368b0
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions EZOut.commands.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -6377,7 +6377,7 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))

# If provided, will colorize all rows in a table, according to the script block.
# If the script block returns a value, it will be treated either as an ANSI escape sequence or up to two hexadecimal colors
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('ColourRow')]
[ScriptBlock]$ColorRow,

Expand Down Expand Up @@ -6409,20 +6409,21 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))

# If provided, the table view will only be used if the the typename includes this value.
# This is distinct from the overall typename, and can be used to have different table views for different inherited objects.
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$ViewTypeName,

# If provided, the table view will only be used if the the typename is in a SelectionSet.
# This is distinct from the overall typename, and can be used to have different table views for different inherited objects.
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$ViewSelectionSet,

# If provided, will selectively display items.
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Parameter(ValueFromPipelineByPropertyName)]
[ScriptBlock]
$ViewCondition)
$ViewCondition
)

begin {
$rowEntries = @()
Expand All @@ -6431,9 +6432,25 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))
if ($_ -is [scriptblock]) { "`$(`$Script:_LastCellStyle = `$(`$__ = `$_;. {$($_)};`$_ = `$__);`$Script:_LastCellStyle)"}
else { "`$(`$Script:_LastCellStyle ='$($_)';`$Script:_LastCellStyle)" }
}

$myParameterNames = @(($MyInvocation.MyCommand -as [Management.Automation.CommandMetadata]).Keys) -as [string[]]
}

process {
# ValueFromPipelineByPropertyName is great, but it is "sticky".
# Parameters that have been bound aren't "unbound" until a new value is provided.
# This means that if a parameter is not provided, it will keep the last value.
# And that's what we call an unexpected side effect.
# In order to avoid this, we walk over our list of parameter names
foreach ($parameterName in $myParameterNames) {
# if they are not in the bound parameters
if (-not $PSBoundParameters.ContainsKey($parameterName)) {
# we nullify them
try { $ExecutionContext.SessionState.PSVariable.Set($parameterName, $null) }
# and if we can't, we write a verbose message.
catch { Write-Verbose "Could not nullify '$parameterName': $_ " }
}
}
$tableHeader = ''
$rowColumns =
@(for ($i =0; $i -lt $property.Count; $i++) {
Expand Down

0 comments on commit b7368b0

Please sign in to comment.