Private/Section.ps1
|
# The Section primitive. # # A Section is evidence for a second-level Technician: a detail table or text block backing # up the Findings. It carries no judgement, and like a Finding it is a value - rendering it # is the Report's job, not the Kind's. function New-Section { [CmdletBinding()] [OutputType([psobject])] param( [Parameter(Mandatory)][string]$Title, # Rows of a detail table. Rendered as a table by the Report. [AllowNull()][AllowEmptyCollection()]$Row, # Text shown as-is. Rendered preformatted by the Report. [AllowNull()][AllowEmptyString()][string]$Text, [ValidateSet('user', 'admin')][string]$Privilege = 'user' ) $rows = @($Row | Where-Object { $null -ne $_ }) if (-not $rows.Count -and -not $Text) { return } [pscustomobject]@{ PSTypeName = 'Gutcheck.Section' Title = $Title Row = $rows Text = $Text Privilege = $Privilege.ToLowerInvariant() } } function Set-SectionPrivilege { [CmdletBinding()] [OutputType([psobject])] param( [Parameter(Mandatory, ValueFromPipeline)]$Section, [Parameter(Mandatory)][ValidateSet('user', 'admin')][string]$Privilege ) process { $Section.Privilege = $Privilege.ToLowerInvariant() $Section } } |