public/Add-ModuleProperty.ps1
function Add-ModuleProperty { [CmdletBinding(DefaultParameterSetName = "NoH")] param ( [Parameter(Mandatory, Position = 1, ValueFromPipeline, ParameterSetName = "NoH")] [Parameter(Mandatory, Position = 1, ValueFromPipeline, ParameterSetName = "H1")] [Parameter(Mandatory, Position = 1, ValueFromPipeline, ParameterSetName = "H2")] [Parameter(Mandatory, Position = 1, ValueFromPipeline, ParameterSetName = "H3")] [PSCustomObject] $HelpDoc, [Parameter(Mandatory, Position = 0, ParameterSetName = "NoH")] [Parameter(Mandatory, Position = 0, ParameterSetName = "H1")] [Parameter(Mandatory, Position = 0, ParameterSetName = "H2")] [Parameter(Mandatory, Position = 0, ParameterSetName = "H3")] [ValidateSet('Name', 'Author', 'Description', 'HelpInfoUri', 'LicenseUri', 'ProjectUri', 'Version')] [string] $Property, [Parameter(ParameterSetName = "H1")] [Switch] $H1, [Parameter(ParameterSetName = "H2")] [Switch] $H2, [Parameter(ParameterSetName = "H3")] [Switch] $H3 ) begin { } process { $heading = [string]::Empty switch ($true) { $H1 { $heading = '# ' } $H2 { $heading = '## ' } $H3 { $heading = '### ' } Default {} } $HelpDoc.Text += '{0}{1}{2}{2}' -f $heading, $HelpDoc.HelpModuleData.$Property, [System.Environment]::NewLine $HelpDoc | Write-Output } end { } } |