PSKoans.format.ps1xml
<?xml version="1.0" encoding="utf-16"?> <!-- Generated with EZOut 1.8.3.1: Install-Module EZOut or https://github.com/StartAutomating/EZOut --> <Configuration> <Controls> <Control> <Name>Prompt.Preface</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text> Welcome, seeker of enlightenment. Let us observe your karma...</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.Describe</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Error'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> 'Describing "{0}" has damaged your karma.' -f $_ </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.Expectation</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text> You have not yet reached enlightenment. The answers you seek...</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Error'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <PropertyName>Expectation</PropertyName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.Meditation</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text> Please meditate on the following code:</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Error'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> @" {0} It "{1}" {2} "@ -f [char]0xd7, $_.It, $_.Meditation </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.Koan</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Emphasis'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> & (Get-Module -Name PSKoans) { $ReplacementPattern = '$1 {0} ' -f [char]0x258c (Get-Random -InputObject $script:MeditationStrings) -replace '^|(\r?\n)', $ReplacementPattern } </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.TopicList</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $TopicList = $_.Topics -replace '^', ' - ' -join [Environment]::NewLine $TopicOrTopics = if ($_.Count -gt 1) { 'topics' } else { 'topic' } $_.FormatString -f $TopicOrTopics, $TopicList </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.ProgressPreamble</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> -not $_.Complete </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @" You examine the path beneath your feet... "@ </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.Complete </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @" You cast your gaze back upon the path that you have walked... "@ </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.ProgressBar</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Progress'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $ConsoleWidth = ($host.UI.RawUI.WindowSize.Width, $host.UI.RawUI.BufferSize.Width, 80).Where{ $_ -ge 30 }[0] $TopicProgressAmount = "{0}/{1}" -f $_.Completed, $_.Total $ProgressWidth = $ConsoleWidth * $_.Width - ($_.Name.Length + $TopicProgressAmount.Length + 7) [int] $PortionDone = ($_.Completed / $_.Total) * $ProgressWidth " [{3}]: [{0}{1}] {2}" -f @( "$([char]0x25a0)" * $PortionDone "$([char]0x2015)" * ($ProgressWidth - $PortionDone) $TopicProgressAmount $_.Name ) </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.End</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text>Run 'Show-Karma -Meditate' to begin your meditations.</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>Prompt.Details</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <NewLine /> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.Describe -and $_.Describe -ne $global:_Koan_Describe </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> $global:_Koan_Describe = $_.Describe $Indent = " " * 4 '{0}Describing {1}{2}' -f $Indent, $_.Describe, [Environment]::NewLine </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Emphasis'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.Context -and $_.Context -ne $global:_Koan_Context </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> $global:_Koan_Context = $_.Context $IndentSpaces = 4 if ($_.Context) { $IndentSpaces += 2 } $Indent = " " * $IndentSpaces '{0}{1}{2}' -f $Indent, $_.Context, [Environment]::NewLine </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Passed'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.Passed </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> $IndentSpaces = 4 if ($_.Context) { $IndentSpaces += 4 } elseif ($_.Describe) { $Indent += 2 } $Indent = " " * $IndentSpaces '{0}[{1}] It {2}' -f $Indent, [char]0x25b8, $_.Name </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Error'</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> -not $_.Passed </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> $IndentSpaces = 4 if ($_.Context) { $IndentSpaces += 4 } elseif ($_.Describe) { $Indent += 2 } $Indent = " " * $IndentSpaces '{0}[{1}] It {2}' -f $Indent, [char]0xd7, $_.Name </ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>${PSKoans_SetOutputStyle}</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock><# .Synopsis Adds style to a format output .Description Adds style information to a format output, including: * ForegroundColor * BackgroundColor * Bold * Underline .Notes Stylized Output works in two contexts at present: * Rich consoles (Windows Terminal, PowerShell.exe, Pwsh.exe) (when $host.UI.SupportsVirtualTerminal) * Web pages (Based off the presence of a $Request variable, or when $host.UI.SupportsHTML (you must add this property to $host.UI)) IsFormatPart: true #> param( [string]$ForegroundColor, [string]$BackgroundColor, [switch]$Bold, [switch]$Underline, [switch]$Invert ) $canUseANSI = $host.UI.SupportsVirtualTerminal $canUseHTML = $Request -or $host.UI.SupportsHTML if (-not ($canUseANSI -or $canUseHTML)) { return } $knownStreams = @{ Output='';Error='BrightRed';Warning='BrightYellow'; Verbose='BrightCyan';Debug='Yellow';Progress='Cyan'; Success='BrightGreen';Failure='Red';Default=''} $standardColors = 'Black', 'Red', 'Green', 'Yellow', 'Blue','Magenta', 'Cyan', 'White' $brightColors = 'BrightBlack', 'BrightRed', 'BrightGreen', 'BrightYellow', 'BrightBlue','BrightMagenta', 'BrightCyan', 'BrightWhite' $n =0 $cssClasses = @() $styleAttributes = @(:nextColor foreach ($hc in $ForegroundColor,$BackgroundColor) { $n++ if (-not $hc) { continue } if ($hc[0] -eq [char]0x1b) { if ($canUseANSI) { $hc; continue } } $ansiStartPoint = if ($n -eq 1) { 30 } else { 40 } if ($knownStreams.ContainsKey($hc)) { $i = $brightColors.IndexOf($knownStreams[$hc]) if ($canUseHTML) { $cssClasses += $hc } else { if ($i -ge 0 -and $canUseANSI) { '' + [char]0x1b + "[1;$($ansiStartPoint + $i)m" } else { $i = $standardColors.IndexOf($knownStreams[$hc]) if ($i -ge 0 -and $canUseANSI) { '' + [char]0x1b + "[1;$($ansiStartPoint + $i)m" } elseif ($i -le 0 -and $canUseANSI) { '' + [char]0x1b + "[$($ansistartpoint + 8):5m" } } } continue nextColor } elseif ($standardColors -contains $hc) { for ($i = 0; $i -lt $standardColors.Count;$i++) { if ($standardColors[$i] -eq $hc) { if ($canUseANSI -and -not $canUseHTML) { '' + [char]0x1b + "[$($ansiStartPoint + $i)m" } else { $cssClasses += $standardColors[$i] } continue nextColor } } } elseif ($brightColors -contains $hc) { for ($i = 0; $i -lt $brightColors.Count;$i++) { if ($brightColors[$i] -eq $hc) { if ($canUseANSI -and -not $canUseHTML) { '' + [char]0x1b + "[1;$($ansiStartPoint + $i)m" } else { $cssClasses += $standardColors[$i] } continue nextColor } } } if ($hc -and -not $hc.StartsWith('#')) { $placesToLook= @(if ($hc.Contains('.')) { $module, $setting = $hc -split '\.', 2 $theModule = Get-Module $module $theModule.PrivateData.Color, $theModule.PrivateData.Colors, $theModule.PrivateData.Colour, $theModule.PrivateData.Colours, $theModule.PrivateData.EZOut, $global:PSColors, $global:PSColours } else { $setting = $hc $moduleColorSetting = $theModule.PrivateData.PSColors.$setting }) foreach ($place in $placesToLook) { if (-not $place) { continue } foreach ($propName in $setting -split '\.') { $place = $place.$propName if (-not $place) { break } } if ($place -and "$place".StartsWith('#') -and 4,7 -contains "$place".Length) { $hc = $place continue } } if (-not $hc.StartsWith -or -not $hc.StartsWith('#')) { continue } } $r,$g,$b = if ($hc.Length -eq 7) { [int]::Parse($hc[1..2]-join'', 'HexNumber') [int]::Parse($hc[3..4]-join '', 'HexNumber') [int]::Parse($hc[5..6] -join'', 'HexNumber') }elseif ($hc.Length -eq 4) { [int]::Parse($hc[1], 'HexNumber') * 16 [int]::Parse($hc[2], 'HexNumber') * 16 [int]::Parse($hc[3], 'HexNumber') * 16 } if ($canUseHTML) { if ($n -eq 1) { "color:$hc" } elseif ($n -eq 2) { "background-color:$hc"} } elseif ($canUseANSI) { if ($n -eq 1) { [char]0x1b+"[38;2;$r;$g;${b}m" } elseif ($n -eq 2) { [char]0x1b+"[48;2;$r;$g;${b}m" } } }) if ($Bold) { $styleAttributes += if ($canUseHTML) { "font-weight:bold" } elseif ($canUseANSI) { [char]0x1b + "[1m" } } if ($Underline) { $styleAttributes += if ($canUseHTML) { "text-decoration:underline" } elseif ($canUseANSI) { [char]0x1b + "[4m" } } if ($Invert) { $styleAttributes += if ($canUseHTML) { "filter:invert(100%)" } elseif ($canUseANSI) { [char]0x1b + "[7m" } } if ($canUseHTML) { "<span$( if ($styleAttributes) { " style='$($styleAttributes -join ';')'"} )$( if ($cssClasses) { " class='$($cssClasses -join ' ')'"} )>" } elseif ($canUseANSI) { $styleAttributes -join '' }</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> <Control> <Name>${PSKoans_ClearOutputStyle}</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock><# .Synopsis Clears the output style .Description Clears ANSI output style or closes the most recent span element. ANSI stylization can be toggled off individually (for instance, to stop applying an -Underline but leave the color unchanged) .Notes IsFormatPart: true #> param( # If set, will explicitly clear ANSI Bold [switch] $Bold, # If set, will explicitly clear ANSI Underline [switch] $Underline, # If set, will explicitly clear ANSI Invert [switch] $Invert, # If set, will explicitly clear ANSI Foreground Color [switch] $ForegroundColor, # If set, will explicitly clear ANSI Background Color [switch] $BackgroundColor ) @(if ($request -or $host.UI.SupportsHTML) { "</span>" } elseif ($Host.UI.SupportsVirtualTerminal) { if ($Underline) { [char]0x1b + "[24m" } if ($Bold) { [char]0x1b + "[21m" } if ($Invert) { [char]0x1b + '[27m' } if ($ForegroundColor) { [char]0x1b + '[39m' } if ($BackgroundColor) { [char]0x1b + '[49m' } if (-not ($Underline -or $Bold -or $Invert -or $ForegroundColor -or $BackgroundColor)) { [char]0x1b + '[0m' } }) -join ''</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </Control> </Controls> <ViewDefinitions> <View> <Name>List</Name> <ViewSelectedBy> <TypeName>PSKoans.CompleteResult</TypeName> </ViewSelectedBy> <ListControl> <ListEntries> <ListEntry> <ListItems> <ListItem> <PropertyName>KoansPassed</PropertyName> </ListItem> <ListItem> <PropertyName>TotalKoans</PropertyName> </ListItem> <ListItem> <PropertyName>RequestedTopic</PropertyName> </ListItem> <ListItem> <PropertyName>Complete</PropertyName> </ListItem> </ListItems> </ListEntry> </ListEntries> </ListControl> </View> <View> <Name>PSKoans.CompleteResult</Name> <ViewSelectedBy> <TypeName>PSKoans.CompleteResult</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ FormatString = @" Congratulations! You have taken the first steps towards enlightenment. You have completed the {0}: {1} "@ Topics = $_.RequestedTopic } </ScriptBlock> <CustomControlName>Prompt.TopicList</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock>$moduleName = 'PSKoans' do { $lm = Get-Module -Name $moduleName -ErrorAction Ignore if (-not $lm) { continue } if ($lm.FormatPartsLoaded) { break } $wholeScript = @(foreach ($formatFilePath in $lm.exportedFormatFiles) { foreach ($partNodeName in Select-Xml -LiteralPath $formatFilePath -XPath "/Configuration/Controls/Control/Name[starts-with(., '$')]") { $ParentNode = $partNodeName.Node.ParentNode "$($ParentNode.Name)={ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBinding.ScriptBlock)}" } }) -join [Environment]::NewLine New-Module -Name "${ModuleName}.format.ps1xml" -ScriptBlock ([ScriptBlock]::Create(($wholeScript + ';Export-ModuleMember -Variable *'))) | Import-Module -Global $onRemove = [ScriptBlock]::Create("Remove-Module '${ModuleName}.format.ps1xml'") if (-not $lm.OnRemove) { $lm.OnRemove = $onRemove } else { $lm.OnRemove = [ScriptBlock]::Create($onRemove.ToString() + '' + [Environment]::NewLine + $lm.OnRemove) } $lm | Add-Member NoteProperty FormatPartsLoaded $true -Force } while ($false) . ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text> Congratulations! You have made great progress towards enlightenment. The journey to mastery is never-ending; if at any point you feel the need to revisit a topic, you can simply call "Reset-PSKoan -Topic $name" to reset that specific topic and work through it once again. May your newfound knowledge serve you well, and may you find myriad ways to pass it along to others in turn. Mountains are, once again, merely mountains.</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock> 1 </ScriptBlock> <CustomControlName>Prompt.Koan</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.ProgressPreamble</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -gt 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.5 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -eq 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> -not $_.RequestedTopic -or $_.RequestedTopic.Count -gt 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.KoansPassed Total = $_.TotalKoans Name = 'Total' Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <NewLine /> <NewLine /> <ExpressionBinding> <ScriptBlock>. ${PSKoans_SetOutputStyle} -ForegroundColor 'PSKoans.Meditation.Text'</ScriptBlock> </ExpressionBinding> <Text> If you would like to further your studies in this manner, consider investing in "PowerShell by Mistake" by Don Jones - https://leanpub.com/powershell-by-mistake</Text> <ExpressionBinding> <ScriptBlock>. ${PSKoans_ClearOutputStyle}</ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> <View> <Name>PSKoans.KoanInfo</Name> <ViewSelectedBy> <TypeName>PSKoans.KoanInfo</TypeName> </ViewSelectedBy> <TableControl> <TableHeaders> <TableColumnHeader> </TableColumnHeader> <TableColumnHeader> </TableColumnHeader> <TableColumnHeader> </TableColumnHeader> </TableHeaders> <TableRowEntries> <TableRowEntry> <TableColumnItems> <TableColumnItem> <PropertyName>Topic</PropertyName> </TableColumnItem> <TableColumnItem> <PropertyName>Module</PropertyName> </TableColumnItem> <TableColumnItem> <PropertyName>Position</PropertyName> </TableColumnItem> </TableColumnItems> </TableRowEntry> </TableRowEntries> </TableControl> </View> <View> <Name>List</Name> <ViewSelectedBy> <TypeName>PSKoans.Result</TypeName> </ViewSelectedBy> <ListControl> <ListEntries> <ListEntry> <ListItems> <ListItem> <PropertyName>Describe</PropertyName> </ListItem> <ListItem> <PropertyName>It</PropertyName> </ListItem> <ListItem> <PropertyName>Expectation</PropertyName> </ListItem> <ListItem> <PropertyName>Meditation</PropertyName> </ListItem> <ListItem> <PropertyName>KoansPassed</PropertyName> </ListItem> <ListItem> <PropertyName>TotalKoans</PropertyName> </ListItem> <ListItem> <PropertyName>CurrentTopic</PropertyName> </ListItem> </ListItems> </ListEntry> </ListEntries> </ListControl> </View> <View> <Name>Meditation</Name> <ViewSelectedBy> <TypeName>PSKoans.Result</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock> 1 </ScriptBlock> <CustomControlName>Prompt.Preface</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_.Describe </ScriptBlock> <CustomControlName>Prompt.Describe</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.Expectation</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.Meditation</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> 1 </ScriptBlock> <CustomControlName>Prompt.Koan</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Topics = $_.RequestedTopic FormatString = @" You must meditate further on your selected {0}: {1} "@ } </ScriptBlock> <CustomControlName>Prompt.TopicList</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.ProgressPreamble</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -ne 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.5 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -eq 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> -not $_.RequestedTopic -or $_.RequestedTopic.Count -gt 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.KoansPassed Total = $_.TotalKoans Name = 'Total' Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> 1 </ScriptBlock> <CustomControlName>Prompt.End</CustomControlName> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> <View> <Name>Detailed</Name> <ViewSelectedBy> <TypeName>PSKoans.Result</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.Expectation</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.Meditation</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> 1 </ScriptBlock> <CustomControlName>Prompt.Koan</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Topics = $_.RequestedTopic FormatString = @" You must meditate further on your selected {0}: {1} "@ } </ScriptBlock> <CustomControlName>Prompt.TopicList</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> $_ </ScriptBlock> <CustomControlName>Prompt.ProgressPreamble</CustomControlName> </ExpressionBinding> <NewLine /> <ExpressionBinding> <ScriptBlock> $_.Results </ScriptBlock> <EnumerateCollection /> <CustomControlName>Prompt.Details</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -ne 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.5 Newline = $true } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> $_.RequestedTopic.Count -eq 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.CurrentTopic.Completed Total = $_.CurrentTopic.Total Name = $_.CurrentTopic.Name Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> <ExpressionBinding> <ItemSelectionCondition> <ScriptBlock> -not $_.RequestedTopic -or $_.RequestedTopic.Count -gt 1 </ScriptBlock> </ItemSelectionCondition> <ScriptBlock> @{ Completed = $_.KoansPassed Total = $_.TotalKoans Name = 'Total' Width = 0.8 } </ScriptBlock> <CustomControlName>Prompt.ProgressBar</CustomControlName> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> </ViewDefinitions> </Configuration> |