diff --git a/PwshSpectreConsole/private/Start-AnsiConsoleLive.ps1 b/PwshSpectreConsole/private/Start-AnsiConsoleLive.ps1 index 755c175..04d287f 100644 --- a/PwshSpectreConsole/private/Start-AnsiConsoleLive.ps1 +++ b/PwshSpectreConsole/private/Start-AnsiConsoleLive.ps1 @@ -20,9 +20,9 @@ function Start-AnsiConsoleLive { New-Variable -Name $resultVariableName -Scope "Script" [Spectre.Console.AnsiConsole]::Live($Data).Start({ param ( - $ctx + [Spectre.Console.LiveDisplayContext] $Context ) - Set-Variable -Name $resultVariableName -Value (& $ScriptBlock $ctx) -Scope "Script" + Set-Variable -Name $resultVariableName -Value (& $ScriptBlock $Context) -Scope "Script" }) return Get-Variable -Name $resultVariableName -ValueOnly } \ No newline at end of file diff --git a/PwshSpectreConsole/private/Write-SpectreHostInternal.ps1 b/PwshSpectreConsole/private/Write-SpectreHostInternal.ps1 index 730bd54..2fec38f 100644 --- a/PwshSpectreConsole/private/Write-SpectreHostInternal.ps1 +++ b/PwshSpectreConsole/private/Write-SpectreHostInternal.ps1 @@ -1,17 +1,34 @@ +using module ".\completions\Completers.psm1" # Functions required for unit testing write-spectrehost function Write-SpectreHostInternalMarkup { param ( [Parameter(Mandatory)] - [string] $Message + [string] $Message, + [ValidateSet([SpectreConsoleJustify], ErrorMessage = "Value '{0}' is invalid. Try one of: {1}")] + [string]$Justify = "Left", + [switch] $PassThru ) - [Spectre.Console.AnsiConsoleExtensions]::Markup([Spectre.Console.AnsiConsole]::Console, $Message) + $output = [Spectre.Console.Markup]::new($Message) + $output.Justification = [Spectre.Console.Justify]::$Justify + if ($PassThru) { + return $output + } + [Spectre.Console.AnsiConsole]::Write($output) } function Write-SpectreHostInternalMarkupLine { param ( [Parameter(Mandatory)] - [string] $Message + [string] $Message, + [ValidateSet([SpectreConsoleJustify], ErrorMessage = "Value '{0}' is invalid. Try one of: {1}")] + [string]$Justify = "Left", + [switch] $PassThru ) - [Spectre.Console.AnsiConsoleExtensions]::MarkupLine([Spectre.Console.AnsiConsole]::Console, $Message) + $output = [Spectre.Console.Markup]::new($Message) + $output.Justification = [Spectre.Console.Justify]::$Justify + if ($PassThru) { + return $output + } + [Spectre.Console.AnsiConsole]::WriteLine($output) } \ No newline at end of file diff --git a/PwshSpectreConsole/public/config/Set-SpectreColors.ps1 b/PwshSpectreConsole/public/config/Set-SpectreColors.ps1 index f7ed4ea..ed99c9b 100644 --- a/PwshSpectreConsole/public/config/Set-SpectreColors.ps1 +++ b/PwshSpectreConsole/public/config/Set-SpectreColors.ps1 @@ -22,7 +22,7 @@ function Set-SpectreColors { The default table text color to set. Must be a valid Spectre Console color name. Defaults to "Default" which will be the standard console foreground color. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to set the accent color and default value color for Spectre Console. Write-SpectreRule "This is a default rule" Set-SpectreColors -AccentColor "Turquoise2" diff --git a/PwshSpectreConsole/public/demo/Get-SpectreDemoColors.ps1 b/PwshSpectreConsole/public/demo/Get-SpectreDemoColors.ps1 index fa76c15..acc3c7e 100644 --- a/PwshSpectreConsole/public/demo/Get-SpectreDemoColors.ps1 +++ b/PwshSpectreConsole/public/demo/Get-SpectreDemoColors.ps1 @@ -9,7 +9,7 @@ It also provides information on how to use the colors as parameters for commands or in Spectre Console markup. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to use Get-SpectreDemoColors to display a list of the built-in Spectre Console colors. Get-SpectreDemoColors #> diff --git a/PwshSpectreConsole/public/demo/Get-SpectreDemoEmoji.ps1 b/PwshSpectreConsole/public/demo/Get-SpectreDemoEmoji.ps1 index 897ca68..420cd7f 100644 --- a/PwshSpectreConsole/public/demo/Get-SpectreDemoEmoji.ps1 +++ b/PwshSpectreConsole/public/demo/Get-SpectreDemoEmoji.ps1 @@ -11,7 +11,7 @@ Limit the number of emoji returned. This is only really useful for generating the help docs. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to use Get-SpectreDemoEmoji to display a list of the built-in Spectre Console emojis. Get-SpectreDemoEmoji -Count 5 diff --git a/PwshSpectreConsole/public/demo/Get-SpectreDemoFeatures.ps1 b/PwshSpectreConsole/public/demo/Get-SpectreDemoFeatures.ps1 index febace7..7c3f693 100644 --- a/PwshSpectreConsole/public/demo/Get-SpectreDemoFeatures.ps1 +++ b/PwshSpectreConsole/public/demo/Get-SpectreDemoFeatures.ps1 @@ -6,7 +6,7 @@ This script demonstrates the features of Spectre.Console. It shows off the various colors, styles, and other features that Spectre.Console supports. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to use Get-SpectreDemoFeatures to display a list of the features of Spectre.Console as seen on the https://spectreconsole.net/ homepage. Get-SpectreDemoFeatures #> diff --git a/PwshSpectreConsole/public/demo/Start-SpectreDemo.ps1 b/PwshSpectreConsole/public/demo/Start-SpectreDemo.ps1 index b4f6e16..bfddf45 100644 --- a/PwshSpectreConsole/public/demo/Start-SpectreDemo.ps1 +++ b/PwshSpectreConsole/public/demo/Start-SpectreDemo.ps1 @@ -37,7 +37,7 @@ function Start-SpectreDemo { ![Spectre demo animation](/demo.gif) .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to run the PwshSpectreConsole demo. Start-SpectreDemo #> diff --git a/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 b/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 index 1daf42c..9e19335 100644 --- a/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 +++ b/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 @@ -22,7 +22,7 @@ function Start-SpectreRecording { .PARAMETER CountdownAndClear If this switch is present, the console will be cleared and a countdown will be displayed before the recording starts. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to record the spectre console output. $recording = Start-SpectreRecording -RecordingType "Html" -CountdownAndClear # Use spectre console functions, these will be recorded diff --git a/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 b/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 index 3d33caf..d7192dd 100644 --- a/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 +++ b/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 @@ -14,7 +14,7 @@ function Stop-SpectreRecording { .PARAMETER OutputPath The path to save the recording to. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to record the spectre console output. $recording = Start-SpectreRecording -RecordingType "Html" -CountdownAndClear # Use spectre console functions, these will be recorded diff --git a/PwshSpectreConsole/public/formatting/Add-SpectreTableRow.ps1 b/PwshSpectreConsole/public/formatting/Add-SpectreTableRow.ps1 index 6c2d748..899409b 100644 --- a/PwshSpectreConsole/public/formatting/Add-SpectreTableRow.ps1 +++ b/PwshSpectreConsole/public/formatting/Add-SpectreTableRow.ps1 @@ -14,8 +14,7 @@ The table to which the row will be added. An array of renderable items containing the data to be displayed in the columns of this row. .EXAMPLE -# **Example 1** -# This example demonstrates how to add a row to an existing Spectre Console table. +# **Example 1** # This example demonstrates how to add a row to an existing Spectre Console table. $data = @( [pscustomobject]@{Name="John"; Age=25; City="New York"}, [pscustomobject]@{Name="Jane"; Age=30; City="Los Angeles"} diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreAligned.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreAligned.ps1 index 2a47001..7d66ffc 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreAligned.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreAligned.ps1 @@ -19,7 +19,7 @@ function Format-SpectreAligned { The vertical alignment of the object. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to align a string to the right inside a panel. "hello right hand side" | Format-SpectreAligned -HorizontalAlignment Right -VerticalAlignment Middle | Format-SpectrePanel -Expand -Height 9 #> diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreBarChart.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreBarChart.ps1 index cf678cc..b6012eb 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreBarChart.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreBarChart.ps1 @@ -23,7 +23,7 @@ function Format-SpectreBarChart { Hides the values from being displayed on the chart. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a bar chart of various data points. $data = @() diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreBreakdownChart.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreBreakdownChart.ps1 index 1dd5c4a..fb0a7db 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreBreakdownChart.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreBreakdownChart.ps1 @@ -23,7 +23,7 @@ function Format-SpectreBreakdownChart { Hides the tag values on the chart. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a breakdown chart of various data points. $data = @() diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreColumns.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreColumns.ps1 index 25228ed..7dddbad 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreColumns.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreColumns.ps1 @@ -20,7 +20,7 @@ function Format-SpectreColumns { A switch to expand the columns to fill the available space. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a collection of strings in columns. @("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit,", "sed", "do", "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua.", "Ut", "enim", "ad", "minim", @@ -30,12 +30,12 @@ function Format-SpectreColumns { "cupidatat", "non", "proident", "sunt", "in", "culpa") | Foreach-Object { $_ } | Format-SpectreColumns .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to display a collection of panels that are expanded but with normal sized columns. @("left", "middle", "right") | Foreach-Object { $_ | Format-SpectrePanel -Expand } | Format-SpectreColumns .EXAMPLE - # **Example 3** + # **Example 3** # This example demonstrates how to display a collection of panels that are expanded and with expanded columns so it takes up the console width. @("left", "middle", "right") | Foreach-Object { $_ | Format-SpectrePanel -Expand } | Format-SpectreColumns -Expand #> diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreException.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreException.ps1 index 40e6263..a7deb67 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreException.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreException.ps1 @@ -33,8 +33,7 @@ The style to use when rendering the exception provided as a hashtable. e.g. ``` .EXAMPLE -# **Example 1** -# This example demonstrates how to format an exception into a Spectre Console Exception with syntax highlighting. +# **Example 1** # This example demonstrates how to format an exception into a Spectre Console Exception with syntax highlighting. try { Get-ChildItem -BadParam -ErrorAction Stop } catch { diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 index d55fe8e..eb8ea47 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 @@ -10,12 +10,12 @@ function Format-SpectreGrid { See https://spectreconsole.net/widgets/grid for more information. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a grid of rows using the Spectre Console module with a list of lists. Format-SpectreGrid -Data @("hello", "I", "am"), @("a", "grid", "of"), @("rows", "using", "spectre") .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to display a grid of rows using the Spectre Console module with a list of `New-SpectreGridRow` objects. # The `New-SpectreGridRow` function is used to create the rows when you want to avoid array collapsing in PowerShell turning your rows into a single array of columns. $rows = 4 diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreJson.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreJson.ps1 index b8a6d69..267ab6d 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreJson.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreJson.ps1 @@ -71,7 +71,7 @@ function Format-SpectreJson { ``` .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to format an array of objects into a Spectre Console Json object with syntax highlighting. $data = @( [pscustomobject]@{ diff --git a/PwshSpectreConsole/public/formatting/Format-SpectrePadded.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectrePadded.ps1 index 9bb2138..47d96be 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectrePadded.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectrePadded.ps1 @@ -13,17 +13,17 @@ function Format-SpectrePadded { A renderable item to wrap in padding. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to pad an item with a padding of 1 on all sides "Item to pad" | Format-SpectrePadded -Padding 1 | Format-SpectrePanel .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to pad an item with a padding of 4 on all sides "Item to pad" | Format-SpectrePadded -Padding 4 | Format-SpectrePanel .EXAMPLE - # **Example 3** + # **Example 3** # This example demonstrates how to pad an item with different padding on each side. "Item to pad" | Format-SpectrePadded -Top 4 -Left 10 -Right 1 -Bottom 1 | Format-SpectrePanel #> diff --git a/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 index 3ddebc8..2671d95 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 @@ -32,12 +32,12 @@ function Format-SpectrePanel { The height of the panel. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a panel with a title and a rounded border. Format-SpectrePanel -Data "Hello, world!" -Title "My Panel" -Border "Rounded" -Color "Red" .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to display a panel with a title and a double border that's expanded to take up the whole console width. "Hello, big panel!" | Format-SpectrePanel -Title "My Big Panel" -Border "Double" -Color "Magenta1" -Expand #> diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreRows.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreRows.ps1 index ad1eb05..77d5952 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreRows.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreRows.ps1 @@ -14,12 +14,12 @@ function Format-SpectreRows { An array of renderable items containing the data to be displayed in the rows. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a collection of strings in rows. @("top", "middle", "bottom") | Format-SpectreRows .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to display a collection of renderable items as rows inside a panel, without wrapping the renderables in rows you cannot display them in a panel because a panel only accepts a single item. $rows = @() for ($i = 0; $i -lt 12; $i+= 4) { diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 index 09168fd..534798f 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 @@ -63,7 +63,7 @@ function Format-SpectreTable { Take up all of the horizontal space available. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to format an array of objects into a Spectre Console table. $data = @( [pscustomobject]@{Name="John"; Age=25; City="New York"}, @@ -72,7 +72,7 @@ function Format-SpectreTable { Format-SpectreTable -Data $data .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to format an array of objects into a Spectre Console table with custom properties generated by scriptblock expressions. $Properties = @( # foreground + background @@ -85,12 +85,12 @@ function Format-SpectreTable { Get-ChildItem | Format-SpectreTable -Property $Properties -AllowMarkup .EXAMPLE - # **Example 3** + # **Example 3** # This example demonstrates how to format an array of scalar objects into a Spectre Console table. 1..10 | Format-SpectreTable -Title Numbers .EXAMPLE - # **Example 4** + # **Example 4** # This example demonstrates how to nest other renderable objects inside a table. $calendar = Write-SpectreCalendar -Date (Get-Date) -PassThru diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreTextPath.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreTextPath.ps1 index bd91551..a240939 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreTextPath.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreTextPath.ps1 @@ -14,7 +14,7 @@ function Format-SpectreTextPath { The directory/file path to format .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to format a PowerShell path as a Spectre Console Path with syntax highlighting. Get-Location | Format-SpectreTextPath | Out-SpectreHost #> diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreTree.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreTree.ps1 index 6ad57a7..9bed1c4 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreTree.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreTree.ps1 @@ -20,7 +20,7 @@ function Format-SpectreTree { The color to use for the tree. This can be a Spectre Console color name or a hex color code. Default is the accent color defined in the script. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display a tree with multiple children. $calendar = Write-SpectreCalendar -Date 2024-07-01 -PassThru $data = @{ diff --git a/PwshSpectreConsole/public/formatting/New-SpectreChartItem.ps1 b/PwshSpectreConsole/public/formatting/New-SpectreChartItem.ps1 index e8ad6bb..3b62cd0 100644 --- a/PwshSpectreConsole/public/formatting/New-SpectreChartItem.ps1 +++ b/PwshSpectreConsole/public/formatting/New-SpectreChartItem.ps1 @@ -19,8 +19,7 @@ The value for the chart item. The color for the chart item. Must be a valid Spectre color as name, hex or a Spectre.Console.Color object. .EXAMPLE -# **Example 1** -# This example demonstrates how to use SpectreChartItems to create a breakdown chart. +# **Example 1** # This example demonstrates how to use SpectreChartItems to create a breakdown chart. $data = @() $data += New-SpectreChartItem -Label "Sales" -Value 1000 -Color "green" $data += New-SpectreChartItem -Label "Expenses" -Value 500 -Color "#ff0000" diff --git a/PwshSpectreConsole/public/formatting/New-SpectreGridRow.ps1 b/PwshSpectreConsole/public/formatting/New-SpectreGridRow.ps1 index e2e7853..62e8186 100644 --- a/PwshSpectreConsole/public/formatting/New-SpectreGridRow.ps1 +++ b/PwshSpectreConsole/public/formatting/New-SpectreGridRow.ps1 @@ -8,9 +8,11 @@ Creates a new SpectreGridRow object with the specified columns for use in Format .PARAMETER Data An array of renderable items containing the data to be displayed in the columns of this row. +.PARAMETER Justify +The justification to apply to each data item in this row. The default is Left. + .EXAMPLE -# **Example 1** -# This example demonstrates how to create a grid with two rows and three columns. +# **Example 1** # This example demonstrates how to create a grid with two rows and three columns. $columns = @() $columns += "Column 1" | Format-SpectrePanel $columns += "Column 2" | Format-SpectrePanel @@ -26,7 +28,7 @@ $rows | Format-SpectreGrid function New-SpectreGridRow { [Reflection.AssemblyMetadata("title", "New-SpectreGridRow")] param ( - [Parameter(Mandatory)] + [Parameter(ValueFromPipeline, Mandatory)] [array]$Data ) diff --git a/PwshSpectreConsole/public/formatting/New-SpectreLayout.ps1 b/PwshSpectreConsole/public/formatting/New-SpectreLayout.ps1 index 830bb46..ebaca03 100644 --- a/PwshSpectreConsole/public/formatting/New-SpectreLayout.ps1 +++ b/PwshSpectreConsole/public/formatting/New-SpectreLayout.ps1 @@ -28,8 +28,7 @@ e.g. in the example below to update the contents of row1 you would use `$root = The minimum size of the layout, this can be used to ensure a layout is at least the minimum width. .EXAMPLE -# **Example 1** -# This example demonstrates how to create a layout with a calendar, a list of files, and a panel with a calendar aligned to the middle and center. +# **Example 1** # This example demonstrates how to create a layout with a calendar, a list of files, and a panel with a calendar aligned to the middle and center. $calendar = Write-SpectreCalendar -Date (Get-Date) -PassThru $files = Get-ChildItem | Format-SpectreTable | Format-SpectreAligned -HorizontalAlignment Right -VerticalAlignment Bottom diff --git a/PwshSpectreConsole/public/images/Get-SpectreImage.ps1 b/PwshSpectreConsole/public/images/Get-SpectreImage.ps1 index 361db33..c8de8a7 100644 --- a/PwshSpectreConsole/public/images/Get-SpectreImage.ps1 +++ b/PwshSpectreConsole/public/images/Get-SpectreImage.ps1 @@ -14,7 +14,7 @@ function Get-SpectreImage { The maximum width of the image. If not specified, the image will be displayed at its original size. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display an image in the console. Get-SpectreImage -ImagePath ".\private\images\smiley.png" -MaxWidth 40 #> diff --git a/PwshSpectreConsole/public/images/Get-SpectreImageExperimental.ps1 b/PwshSpectreConsole/public/images/Get-SpectreImageExperimental.ps1 index 0918b9a..0240063 100644 --- a/PwshSpectreConsole/public/images/Get-SpectreImageExperimental.ps1 +++ b/PwshSpectreConsole/public/images/Get-SpectreImageExperimental.ps1 @@ -27,12 +27,12 @@ function Get-SpectreImageExperimental { The resampling algorithm to use when scaling the image. Valid values are "Bicubic" and "NearestNeighbor". The default value is "Bicubic". .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to display an animated image in the console that loops 4 times. Get-SpectreImageExperimental -ImagePath ".\private\images\harveyspecter.gif" -LoopCount 4 -Width 82 .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to display a static image in the console. Get-SpectreImageExperimental -ImagePath ".\private\images\smiley.png" -Width 80 #> diff --git a/PwshSpectreConsole/public/progress/Add-SpectreJob.ps1 b/PwshSpectreConsole/public/progress/Add-SpectreJob.ps1 index a312c29..2351fce 100644 --- a/PwshSpectreConsole/public/progress/Add-SpectreJob.ps1 +++ b/PwshSpectreConsole/public/progress/Add-SpectreJob.ps1 @@ -21,7 +21,7 @@ function Add-SpectreJob { The PowerShell job to add to the context. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to add two jobs to a context and wait for them to complete. $jobOutcomes = Invoke-SpectreCommandWithProgress -ScriptBlock { param ( diff --git a/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithProgress.ps1 b/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithProgress.ps1 index 39f7f2e..4186b7c 100644 --- a/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithProgress.ps1 +++ b/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithProgress.ps1 @@ -11,7 +11,7 @@ function Invoke-SpectreCommandWithProgress { The script block to execute. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a 4-stage process with one loading bar that loads in four chunks. Invoke-SpectreCommandWithProgress -ScriptBlock { param ( @@ -31,7 +31,7 @@ function Invoke-SpectreCommandWithProgress { } .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates a 2-stage process with two loading bars running in parallel. Invoke-SpectreCommandWithProgress -ScriptBlock { param ( @@ -64,7 +64,7 @@ function Invoke-SpectreCommandWithProgress { } .EXAMPLE - # **Example 3** + # **Example 3** # This example demonstrates a task with an unknown (indeterminate) duration. $result = Invoke-SpectreCommandWithProgress -ScriptBlock { param ( @@ -81,7 +81,7 @@ function Invoke-SpectreCommandWithProgress { Write-SpectreHost "Result: $result" .EXAMPLE - # **Example 4** + # **Example 4** # This example demonstrates a job with an estimated duration, after the estimated duration has passed the job will switch to an indeterminate state. $result = Invoke-SpectreCommandWithProgress -ScriptBlock { param ( diff --git a/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithStatus.ps1 b/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithStatus.ps1 index 87dad17..343624b 100644 --- a/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithStatus.ps1 +++ b/PwshSpectreConsole/public/progress/Invoke-SpectreCommandWithStatus.ps1 @@ -22,7 +22,7 @@ function Invoke-SpectreCommandWithStatus { The color of the spinner. Valid values can be found with Get-SpectreDemoColors. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to show a spinner while doing some work. Write-SpectreHost is used to update the host with progress without breaking the spinner animation. $result = Invoke-SpectreCommandWithStatus -Spinner "Dots2" -Title "Showing a spinner..." -ScriptBlock { # Write updates to the host using Write-SpectreHost diff --git a/PwshSpectreConsole/public/progress/Invoke-SpectreScriptBlockQuietly.ps1 b/PwshSpectreConsole/public/progress/Invoke-SpectreScriptBlockQuietly.ps1 index b9e73df..acbb0d8 100644 --- a/PwshSpectreConsole/public/progress/Invoke-SpectreScriptBlockQuietly.ps1 +++ b/PwshSpectreConsole/public/progress/Invoke-SpectreScriptBlockQuietly.ps1 @@ -7,7 +7,7 @@ This function invokes a script block in a background job and returns the output. It also provides an option to suppress the output even more if there is garbage being printed to stderr if using Level = Quieter. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to use this function to suppress all output from a script block so it doesn't break the progress bar. $result = Invoke-SpectreCommandWithProgress { param ( diff --git a/PwshSpectreConsole/public/progress/Wait-SpectreJobs.ps1 b/PwshSpectreConsole/public/progress/Wait-SpectreJobs.ps1 index 9fb922a..c3b08bf 100644 --- a/PwshSpectreConsole/public/progress/Wait-SpectreJobs.ps1 +++ b/PwshSpectreConsole/public/progress/Wait-SpectreJobs.ps1 @@ -24,7 +24,7 @@ function Wait-SpectreJobs { The estimated duration of the jobs in seconds. This is used to calculate the progress of the jobs if the job progress is not available. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to add two jobs to a context and wait for them to complete. Invoke-SpectreCommandWithProgress -ScriptBlock { param ( diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreConfirm.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreConfirm.ps1 index fe8b142..279806c 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreConfirm.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreConfirm.ps1 @@ -22,7 +22,7 @@ function Read-SpectreConfirm { The text and markup to display if the user chooses no. If left undefined, nothing will display. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a simple confirmation prompt with a success message. $answer = Read-SpectreConfirm -Prompt "Would you like to continue the preview installation of [#7693FF]PowerShell 7?[/]" ` -ConfirmSuccess "Woohoo! The internet awaits your elite development contributions." ` diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 index 46e5f78..50b5840 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 @@ -28,7 +28,7 @@ function Read-SpectreMultiSelection { Allow the multi-selection to be submitted without any options chosen. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a multi-selection prompt with a custom title and choices. $fruits = Read-SpectreMultiSelection -Title "Select your favourite fruits" ` -Choices @("apple", "banana", "orange", "pear", "strawberry", "durian", "lemon") ` diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 index f0e87ce..b1c29f4 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 @@ -28,7 +28,7 @@ function Read-SpectreMultiSelectionGrouped { Allow the multi-selection to be submitted without any options chosen. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a multi-selection prompt with grouped choices. $selected = Read-SpectreMultiSelectionGrouped -Title "Select your favorite colors" -PageSize 8 -Choices @( @{ diff --git a/PwshSpectreConsole/public/prompts/Read-SpectrePause.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectrePause.ps1 index a63d861..babfde4 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectrePause.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectrePause.ps1 @@ -17,7 +17,7 @@ function Read-SpectrePause { # Type "↲" to dismiss the message .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to use the Read-SpectrePause function with the AnyKey parameter. Read-SpectrePause -Message "Press the [red]ANY[/] key to continue, when you press it this message will disappear..." # Type "x" to dismiss the message diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreSelection.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreSelection.ps1 index 2e9f3d9..8fbaf51 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreSelection.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreSelection.ps1 @@ -32,14 +32,14 @@ function Read-SpectreSelection { The color of the search highlight in the selection prompt. Defaults to a slightly brighter version of the accent color. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a selection prompt with a custom title and choices. $color = Read-SpectreSelection -Title "Select your favorite color" -Choices @("Red", "Green", "Blue") -Color "Green" # Type "↓", "↓", "↓", "↓", "↲" to wrap around the list and choose green Write-SpectreHost "Your chosen color is '$color'" .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates a selection prompt with a custom title and choices, and search enabled. $color = Read-SpectreSelection -Title "Select your favorite color" -Choices @("Blue", "Bluer", "Blue-est") -EnableSearch # Type "b", "l", "u", "e", "r", "↲" to choose "Bluer" diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 index 06a025a..d1824a8 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 @@ -31,21 +31,21 @@ function Read-SpectreText { With autocomplete and can tab through the choices. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates a simple text prompt with a default answer. $name = Read-SpectreText -Question "What's your name?" -DefaultAnswer "Prefer not to say" # Type "↲" to provide no answer Write-SpectreHost "Your name is '$name'" .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates a simple text prompt with a default answer and a color. $favouriteColor = Read-SpectreText -Question "What's your favorite color?" -DefaultAnswer "pink" # Type "orange", "↲" to enter your favourite color Write-SpectreHost "Your favourite color is '$favouriteColor'" .EXAMPLE - # **Example 3** + # **Example 3** # This example demonstrates a simple text prompt with a default answer, a color, and a list of choices. $favouriteColor = Read-SpectreText -Question "What's your favorite color?" -AnswerColor "Cyan1" -Choices "Black", "Green", "Magenta", "I'll never tell!" # Type "orange", "↲", "magenta", "↲" to enter text that must match a choice in the choices list, orange will be rejected, magenta will be accepted diff --git a/PwshSpectreConsole/public/writing/Get-SpectreEscapedText.ps1 b/PwshSpectreConsole/public/writing/Get-SpectreEscapedText.ps1 index 8e08ab8..53b0db0 100644 --- a/PwshSpectreConsole/public/writing/Get-SpectreEscapedText.ps1 +++ b/PwshSpectreConsole/public/writing/Get-SpectreEscapedText.ps1 @@ -13,7 +13,7 @@ function Get-SpectreEscapedText { The text to be escaped. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to escape text for use in Spectre Console. $data = "][[][red]]][[/][][][" Format-SpectrePanel -Title "Unescaped data" -Data "I want escaped $($data | Get-SpectreEscapedText) [yellow]and[/] [red]unescaped[/] data" diff --git a/PwshSpectreConsole/public/writing/Out-SpectreHost.ps1 b/PwshSpectreConsole/public/writing/Out-SpectreHost.ps1 index bdc5767..e0ba0d9 100644 --- a/PwshSpectreConsole/public/writing/Out-SpectreHost.ps1 +++ b/PwshSpectreConsole/public/writing/Out-SpectreHost.ps1 @@ -16,7 +16,7 @@ function Out-SpectreHost { The default host customitem formatter has some restrictions, it needs to be one char less wide than when outputting to the standard console or it will wrap. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to write a spectre renderable object to the console host. $table = Get-ChildItem | Select-Object Name, Length, LastWriteTime | Format-SpectreTable $table | Out-SpectreHost diff --git a/PwshSpectreConsole/public/writing/Write-SpectreCalendar.ps1 b/PwshSpectreConsole/public/writing/Write-SpectreCalendar.ps1 index 8954876..b4dcb2a 100644 --- a/PwshSpectreConsole/public/writing/Write-SpectreCalendar.ps1 +++ b/PwshSpectreConsole/public/writing/Write-SpectreCalendar.ps1 @@ -35,12 +35,12 @@ function Write-SpectreCalendar { Returns the Spectre Calendar object instead of writing it to the console. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to write a calendar to the console. Write-SpectreCalendar -Date 2024-07-01 -Events @{'2024-07-10' = 'Beach time!'; '2024-07-20' = 'Barbecue' } .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to write a calendar to the console with some event details. $events = @{ '2024-01-10' = 'Hello World!' diff --git a/PwshSpectreConsole/public/writing/Write-SpectreFigletText.ps1 b/PwshSpectreConsole/public/writing/Write-SpectreFigletText.ps1 index 1baf3c8..379f5fe 100644 --- a/PwshSpectreConsole/public/writing/Write-SpectreFigletText.ps1 +++ b/PwshSpectreConsole/public/writing/Write-SpectreFigletText.ps1 @@ -26,12 +26,12 @@ function Write-SpectreFigletText { Returns the Spectre Figlet text object instead of writing it to the console. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to write Figlet text to the console. Write-SpectreFigletText -Text "Hello Spectre!" -Alignment "Center" -Color "Red" .EXAMPLE - # **Example 2** + # **Example 2** # This example demonstrates how to write Figlet text to the console using a custom Figlet font. Write-SpectreFigletText -Text "Whoa?!" -FigletFontPath "..\PwshSpectreConsole.Docs\src\assets\3d.flf" #> diff --git a/PwshSpectreConsole/public/writing/Write-SpectreHost.ps1 b/PwshSpectreConsole/public/writing/Write-SpectreHost.ps1 index 04378d0..fedf8bf 100644 --- a/PwshSpectreConsole/public/writing/Write-SpectreHost.ps1 +++ b/PwshSpectreConsole/public/writing/Write-SpectreHost.ps1 @@ -1,3 +1,5 @@ +using module "..\..\private\completions\Completers.psm1" + function Write-SpectreHost { <# .SYNOPSIS @@ -15,7 +17,7 @@ function Write-SpectreHost { If specified, the message will not be followed by a newline character. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to write a message to the console using Spectre Console markup. Write-SpectreHost -Message "Hello, [blue underline]world[/]! :call_me_hand:" #> @@ -24,21 +26,13 @@ function Write-SpectreHost { [Parameter(ValueFromPipeline, Mandatory)] [object] $Message, [switch] $NoNewline, - [switch] $PassThru + [switch] $PassThru, + [ValidateSet([SpectreConsoleJustify], ErrorMessage = "Value '{0}' is invalid. Try one of: {1}")] + [string]$Justify = "Left" ) - - if ($Message -is [Spectre.Console.Rendering.Renderable]) { - Write-AnsiConsole $Message - return - } - - if ($PassThru) { - return [Spectre.Console.Markup]::new($Message) - } - if ($NoNewline) { - Write-SpectreHostInternalMarkup $Message + return Write-SpectreHostInternalMarkup $Message -Justify $Justify -PassThru:$PassThru } else { - Write-SpectreHostInternalMarkupLine $Message + return Write-SpectreHostInternalMarkupLine $Message -Justify $Justify -PassThru:$PassThru } } \ No newline at end of file diff --git a/PwshSpectreConsole/public/writing/Write-SpectreRule.ps1 b/PwshSpectreConsole/public/writing/Write-SpectreRule.ps1 index 684f5f2..166b7d9 100644 --- a/PwshSpectreConsole/public/writing/Write-SpectreRule.ps1 +++ b/PwshSpectreConsole/public/writing/Write-SpectreRule.ps1 @@ -22,7 +22,7 @@ function Write-SpectreRule { Returns the Spectre Rule object instead of writing it to the console. .EXAMPLE - # **Example 1** + # **Example 1** # This example demonstrates how to write a rule to the console. Write-SpectreRule -Title "My Rule" -Alignment Center -Color Yellow #>