Skip to content

Commit

Permalink
Add caution to recording commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Mar 14, 2024
1 parent 7598e81 commit f3f6c8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions PwshSpectreConsole/public/demo/Start-SpectreRecording.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ Import-NamespaceFromCsFile -Namespace "PwshSpectreConsole.Recording"

$global:SpectreRecordingRecorder = $null
$global:SpectreRecordingOriginalConsole = $null
$global:SpectreRecordingOriginalOutput = $null
$global:SpectreRecordingType = $null

function Start-SpectreRecording {
<#
.SYNOPSIS
Starts a recording of the current console output. This can be used to record a demo of a script or module.
.DESCRIPTION
Starts a recording of the current console output. This can be used to record a demo of a script or module.
Starts a recording of the current console output. This can be used to record all of the spectre console interactions in a PowerShell session.
I've used this to record the examples on the docs help site.
:::caution
This is experimental.
:::
.PARAMETER Width
The width of the recording.
.PARAMETER Height
Expand Down Expand Up @@ -41,6 +44,10 @@ function Start-SpectreRecording {
[switch] $Quiet
)

if(!$global:SpectreRecordingType) {
throw "A $global:SpectreRecordingType recording has already started"
}

if($CountdownAndClear) {
function Test-Recording {
for($i = 3; $i -gt 0; $i--) {
Expand Down
9 changes: 8 additions & 1 deletion PwshSpectreConsole/public/demo/Stop-SpectreRecording.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ function Stop-SpectreRecording {
.SYNOPSIS
Stops a recording of the current console output and returns the recording.
.DESCRIPTION
Stops a recording of the current console output and returns the recording.
Stops a recording of the current console output and returns the recording.
I've used this to record the examples on the docs help site.
:::caution
This is experimental.
:::
.PARAMETER Title
The title of the recording, only used for asciinema recordings.
.PARAMETER OutputPath
Expand Down Expand Up @@ -49,6 +53,9 @@ function Stop-SpectreRecording {

# Reset the console
[Spectre.Console.AnsiConsole]::Console = $global:SpectreRecordingOriginalConsole
$global:SpectreRecordingRecorder = $null
$global:SpectreRecordingOriginalConsole = $null
$global:SpectreRecordingType = $null

# Return the output
if ($OutputPath) {
Expand Down

0 comments on commit f3f6c8d

Please sign in to comment.