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', # Where the Report shows it. Evidence is folded at the end; Top is the box under # the machine's name, for what a reader wants before anything else: what machine # this is. Its rows are Group, Name and Value. [ValidateSet('Evidence', 'Top')][string]$Placement = 'Evidence' ) $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() Placement = $Placement # Stamped on by the Run. See Set-CheckOrigin. CheckName = '' App = '' # The Kind of that Check: what the Report groups the evidence by. Kind = '' } } function Set-SectionPrivilege { [CmdletBinding()] [OutputType([psobject])] param( [Parameter(Mandatory, ValueFromPipeline)]$Section, [Parameter(Mandatory)][ValidateSet('user', 'admin')][string]$Privilege ) process { $Section.Privilege = $Privilege.ToLowerInvariant() $Section } } |