diff --git a/PwshSpectreConsole.Docs/package.json b/PwshSpectreConsole.Docs/package.json index 7f8aa814..c0739a05 100644 --- a/PwshSpectreConsole.Docs/package.json +++ b/PwshSpectreConsole.Docs/package.json @@ -8,7 +8,7 @@ "build": "astro build", "preview": "astro preview", "astro": "astro", - "update-docs": "pwsh -File ./src/powershell/UpdateDocs.ps1" + "update-docs": "pwsh -NoProfile -File ./src/powershell/UpdateDocs.ps1" }, "dependencies": { "@astrojs/starlight": "^0.11.1", diff --git a/PwshSpectreConsole.Docs/src/content/docs/guides/get-started.mdx b/PwshSpectreConsole.Docs/src/content/docs/guides/get-started.mdx index 1a700662..c755335f 100644 --- a/PwshSpectreConsole.Docs/src/content/docs/guides/get-started.mdx +++ b/PwshSpectreConsole.Docs/src/content/docs/guides/get-started.mdx @@ -3,8 +3,6 @@ title: Get Started --- import { TerminalPlayer } from 'astro-terminal-player'; -import readspectreselectionExample1 from '../../../assets/examples/readspectreselectionExample1.cast?url'; -import readspectremultiselectionExample1 from '../../../assets/examples/readspectremultiselectionExample1.cast?url'; ### Demo @@ -36,7 +34,7 @@ Write-SpectreHost "Your chosen color is '$color'" > Example of a user being prompted with a select list: Example of a user being prompted with a multi-select list: ") $inputDelay = Get-Random -Minimum 500 -Maximum 1000 $typingDelay = Get-Random -Minimum 50 -Maximum 200 - $recordingConsole = Start-SpectreRecording -RecordingType "asciinema" -Width 100 -Height 48 -Quiet + $recordingConsole = Start-SpectreRecording -RecordingType "asciinema" -Width 110 -Height 48 Write-Host "Generating sample for:" Write-Host -ForegroundColor DarkGray $code @@ -151,12 +151,13 @@ foreach ($doc in $docs) { $castName = ($doc.Name -replace '.md$', '' -replace '-', '').ToLower() + "Example$example" Set-Content -Path "$asciiCastOutputPath\$castName.cast" -Value $recording - $castUrl += "/examples/$castName.cast';`n" + $castUrl = "/examples/$castName.cast" # Replace the code block with the ascii cast $castTemplate = Get-AsciiCastTemplate -Name $castUrl $content = $content -replace "(?ms)> EXAMPLE $example.+?(``````.+?``````)", "> EXAMPLE $example`n`n`$1`n$castTemplate" } + $content = $content -replace "### Description", "$imports`n### Description" } finally { Pop-Location [Spectre.Console.AnsiConsole]::Console = $originalConsole diff --git a/PwshSpectreConsole/private/classes/PwshSpectreConsole.Recording.cs b/PwshSpectreConsole/private/classes/PwshSpectreConsole.Recording.cs index 0d5852c8..462a32e7 100644 --- a/PwshSpectreConsole/private/classes/PwshSpectreConsole.Recording.cs +++ b/PwshSpectreConsole/private/classes/PwshSpectreConsole.Recording.cs @@ -141,10 +141,9 @@ public class RecordingConsole : IAnsiConsole { private IAnsiConsole _ansiConsole; private AsciiCastWriter _writer; - private bool _quiet; public AsciiCastInput Input { get; } - public RecordingConsole(int width, int height, bool quiet) + public RecordingConsole(int width, int height) { var profileEnrichment = new ProfileEnrichment(); profileEnrichment.UseDefaultEnrichers = false; @@ -168,7 +167,6 @@ public RecordingConsole(int width, int height, bool quiet) console.Profile.Capabilities.Unicode = true; console.Profile.Out = output; - _quiet = quiet; _ansiConsole = console; _writer = asciiCast; Input = new AsciiCastInput(); @@ -205,10 +203,7 @@ public void Clear(bool homeValue) public void Write(IRenderable renderable) { - if(_quiet) - { - _ansiConsole.Write(renderable); - } + _ansiConsole.Write(renderable); } } } diff --git a/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 b/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 index 4d253121..8b09eacf 100644 --- a/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 +++ b/PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1 @@ -1,8 +1,8 @@ Import-NamespaceFromCsFile -Namespace "PwshSpectreConsole.Recording" -$global:SpectreRecordingRecorder = $null -$global:SpectreRecordingOriginalConsole = $null -$global:SpectreRecordingType = $null +$script:SpectreRecordingRecorder = $null +$script:SpectreRecordingOriginalConsole = $null +$script:SpectreRecordingType = $null function Start-SpectreRecording { <# @@ -22,8 +22,6 @@ function Start-SpectreRecording { The type of recording to create. .PARAMETER CountdownAndClear If this switch is present, the console will be cleared and a countdown will be displayed before the recording starts. - .PARAMETER Quiet - If this switch is present all terminal output from spectre console will be suppressed, it will not be visible on the terminal. .EXAMPLE $recording = Start-SpectreRecording -RecordingType "Html" -CountdownAndClear # Use spectre console functions, these will be recorded @@ -40,12 +38,11 @@ function Start-SpectreRecording { [int] $Height = (Get-HostHeight), [ValidateSet("asciinema", "text", "html")] [string] $RecordingType = "asciinema", - [switch] $CountdownAndClear, - [switch] $Quiet + [switch] $CountdownAndClear ) - if($global:SpectreRecordingType) { - throw "A $global:SpectreRecordingType recording has already started" + if($script:SpectreRecordingType) { + throw "A $script:SpectreRecordingType recording has already started" } if($CountdownAndClear) { @@ -61,19 +58,19 @@ function Start-SpectreRecording { } } - $global:SpectreRecordingOriginalConsole = [Spectre.Console.AnsiConsole]::Console + $script:SpectreRecordingOriginalConsole = [Spectre.Console.AnsiConsole]::Console if($RecordingType -eq "asciinema") { # Create a recording console for asciinema, it's a bit fiddlier and requires an iansiconsole that can record durations between frames - $global:SpectreRecordingRecorder = [PwshSpectreConsole.Recording.RecordingConsole]::new($width, $height, $quiet) + $script:SpectreRecordingRecorder = [PwshSpectreConsole.Recording.RecordingConsole]::new($width, $height) } else { # Use the built in recorder - $global:SpectreRecordingRecorder = [Spectre.Console.Recorder]::new($global:SpectreRecordingOriginalConsole) + $script:SpectreRecordingRecorder = [Spectre.Console.Recorder]::new($script:SpectreRecordingOriginalConsole) } # Override current spectre console instance - $global:SpectreRecordingType = $RecordingType - [Spectre.Console.AnsiConsole]::Console = $global:SpectreRecordingRecorder + $script:SpectreRecordingType = $RecordingType + [Spectre.Console.AnsiConsole]::Console = $script:SpectreRecordingRecorder - return $global:SpectreRecordingRecorder + return $script:SpectreRecordingRecorder } diff --git a/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 b/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 index 6046c8e9..fd3e1885 100644 --- a/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 +++ b/PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1 @@ -29,7 +29,7 @@ function Stop-SpectreRecording { [string] $OutputPath ) - if(!$global:SpectreRecordingType) { + if(!$script:SpectreRecordingType) { Write-Warning "No recording in progress" return } @@ -39,23 +39,23 @@ function Stop-SpectreRecording { } # Get the recording - switch ($global:SpectreRecordingType) { + switch ($script:SpectreRecordingType) { "asciinema" { - $recording = $global:SpectreRecordingRecorder.GetAsciiCastRecording($Title) + $recording = $script:SpectreRecordingRecorder.GetAsciiCastRecording($Title) } "text" { - $recording = [Spectre.Console.RecorderExtensions]::ExportText($global:SpectreRecordingRecorder) + $recording = [Spectre.Console.RecorderExtensions]::ExportText($script:SpectreRecordingRecorder) } "html" { - $recording = [Spectre.Console.RecorderExtensions]::ExportHtml($global:SpectreRecordingRecorder) + $recording = [Spectre.Console.RecorderExtensions]::ExportHtml($script:SpectreRecordingRecorder) } } # Reset the console - [Spectre.Console.AnsiConsole]::Console = $global:SpectreRecordingOriginalConsole - $global:SpectreRecordingRecorder = $null - $global:SpectreRecordingOriginalConsole = $null - $global:SpectreRecordingType = $null + [Spectre.Console.AnsiConsole]::Console = $script:SpectreRecordingOriginalConsole + $script:SpectreRecordingRecorder = $null + $script:SpectreRecordingOriginalConsole = $null + $script:SpectreRecordingType = $null # Return the output if ($OutputPath) {