diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..36bd853 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [StartAutomating] diff --git a/.github/workflows/TestAndPublish.yml b/.github/workflows/TestAndPublish.yml index 1923a77..6c437d8 100644 --- a/.github/workflows/TestAndPublish.yml +++ b/.github/workflows/TestAndPublish.yml @@ -576,6 +576,9 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v2 + - name: GitLogger + uses: GitLogging/GitLoggerAction@main + id: GitLogger - name: Use PSSVG Action uses: StartAutomating/PSSVG@main id: PSSVG diff --git a/Assets/Eventful.svg b/Assets/Eventful.svg index 89979d2..677843d 100644 --- a/Assets/Eventful.svg +++ b/Assets/Eventful.svg @@ -1,11 +1,11 @@ - + - - + + @ eventful - \ No newline at end of file + diff --git a/CHANGELOG.md b/CHANGELOG.md index df2e766..e84b81a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,29 +1,42 @@ -## 0.1.7 +## Eventful 0.1.8: + +* Eventful Supports Sponsorship (#25) +* New Commands! + * Import-Event (#28) + * Export-Event (#27) +* Send-Event can now send -EventArguments and -MessageData (#26) +* Watch-Event now supports -MaxTriggerCount and -MessageData (#29) +* Simplifying event source registration (any `@*` script or function) (#30) +* Making one-time event sources more efficient (#31) + +--- + +## Eventful 0.1.7: * Adding On@CommandNotFound event source (Fixes #11) * Watch-Event now allows eventsources -recursively (Fixes #15) --- -## 0.1.6 +## Eventful 0.1.6 * Adding LocationChanged event source (Fixes #12) --- -## 0.1.5 +## Eventful 0.1.5 * Adding On@Event (#2) * Send-Event support for piping existing events (#4) * Adding /docs (#5) --- -## 0.1.4 +## Eventful 0.1.4 * Module Rebranded to Eventful. * Get-EventHandler added --- -## 0.1.3 +## Eventful 0.1.3 New Event Source: * VariableSet @@ -34,7 +47,7 @@ Bugfix: On@Repeat now actually starts it's timer. --- -## 0.1.2 +## Eventful 0.1.2 New Event Source: * UDP @@ -42,7 +55,7 @@ PowerShellAsync Event Source now allows for a -Parameter dictionaries. --- -## 0.1.1 +## Eventful 0.1.1 New Event Sources: * HTTPResponse * PowerShellAsync @@ -54,11 +67,13 @@ New Event Source Capabilities: Event Sources can now return an InitializeEvent property or provide a ComponentModel.InitializationEvent attribute. This will be called directly after the subscription is created, so as to avoid signalling too soon. -## 0.1 +--- + +## Eventful 0.1 + Initial Module Release. Fun simple event syntax (e.g. on mysignal {"do this"} or on delay "00:00:01" {"do that"}) Better pipelining support for Sending events. ---- -'@ \ No newline at end of file +--- \ No newline at end of file diff --git a/@Delay.ps1 b/EventSources/@Delay.ps1 similarity index 72% rename from @Delay.ps1 rename to EventSources/@Delay.ps1 index 9993835..7e21aac 100644 --- a/@Delay.ps1 +++ b/EventSources/@Delay.ps1 @@ -16,7 +16,9 @@ $Wait ) process { - $timer = New-Object Timers.Timer -Property @{Interval=$Wait.TotalMilliseconds;AutoReset=$false} + $timer = New-Object Timers.Timer -Property @{Interval=$Wait.TotalMilliseconds;AutoReset=$false} + $timer | + Add-Member NoteProperty EventName Elapsed -PassThru | + Add-Member NoteProperty MaxTriggerCount 1 -PassThru $timer.Start() - $timer | Add-Member NoteProperty EventName Elapsed -PassThru } \ No newline at end of file diff --git a/@FileChange.ps1 b/EventSources/@FileChange.ps1 similarity index 100% rename from @FileChange.ps1 rename to EventSources/@FileChange.ps1 diff --git a/EventSources/@HttpResponse.ps1 b/EventSources/@HttpResponse.ps1 index f0c09e6..0b86e0b 100644 --- a/EventSources/@HttpResponse.ps1 +++ b/EventSources/@HttpResponse.ps1 @@ -58,7 +58,7 @@ $TransferEncoding = $([Text.Encoding]::UTF8) process { # Clear the event subscriber if one exists. - $eventSubscriber = Get-EventSubscriber -SourceIdentifier "@HttpResponse_Check" -ErrorAction SilentlyContinue + $eventSubscriber = Get-EventSubscriber -SourceIdentifier "@HttpResponse_Check" -ErrorAction Ignore if ($eventSubscriber) {$eventSubscriber | Unregister-Event} # Create a new subscriber for the request. @@ -66,6 +66,7 @@ process { Interval = $PollingInterval.TotalMilliseconds # Every pollinginterval, AutoReset = $true } + $HttpResponseChecker = Register-ObjectEvent -InputObject $httpResponseCheckTimer -EventName Elapsed -Action { $toCallEnd = # check to see if any requests have completed. diff --git a/EventSources/@PowerShellAsync.ps1 b/EventSources/@PowerShellAsync.ps1 index 8fb26b5..2ac3691 100644 --- a/EventSources/@PowerShellAsync.ps1 +++ b/EventSources/@PowerShellAsync.ps1 @@ -83,7 +83,8 @@ process { $psAsync | Add-Member NoteProperty SourceIdentifier @( "PowerShell.Async.$($psAsync.InstanceID)","PowerShell.Async.Failed.$($psAsync.InstanceID)" - ) -Force -PassThru + ) -Force -PassThru | + Add-Member MaxTriggerCount 1 -Force -PassThru return } \ No newline at end of file diff --git a/EventSources/@Process.ps1 b/EventSources/@Process.ps1 index aaa4386..87d3f2e 100644 --- a/EventSources/@Process.ps1 +++ b/EventSources/@Process.ps1 @@ -1,4 +1,4 @@ -<# +<# .Synopsis Watches a process. .Description @@ -48,7 +48,7 @@ process { Add-Member EventName $eventNames -Force -PassThru } else { Get-Process -Id $ProcessID | - Add-Member EventName "Exited" -Force -PassThru + Add-Member EventName "Exited" -Force -PassThru | + Add-Member MaxTriggerCount 1 -Force -PassThru } - } \ No newline at end of file diff --git a/@Repeat.ps1 b/EventSources/@Repeat.ps1 similarity index 100% rename from @Repeat.ps1 rename to EventSources/@Repeat.ps1 diff --git a/@Time.ps1 b/EventSources/@Time.ps1 similarity index 82% rename from @Time.ps1 rename to EventSources/@Time.ps1 index 75ee72a..871a4f9 100644 --- a/@Time.ps1 +++ b/EventSources/@Time.ps1 @@ -8,6 +8,7 @@ #> [Diagnostics.Tracing.EventSource(Name='Elapsed')] param( +# The specific date and time the event will be triggered. [Parameter(Mandatory,Position=0,ParameterSetName='SpecificTime')] [DateTime] $DateTime @@ -24,5 +25,6 @@ process { if (-not $timer) { return } $timer.Start() - return $timer + $timer | + Add-Member NoteProperty MaxTriggerCount 1 -PassThru } diff --git a/EventSources/README.md b/EventSources/README.md new file mode 100644 index 0000000..5a60725 --- /dev/null +++ b/EventSources/README.md @@ -0,0 +1,30 @@ +This directory contains the built-in EventSources in Eventful. + +_Technically speaking_, EventSources can exist in any directory, as long as they are named liked `@*.ps1` and match `^@\w`. + +Event sources within Eventful or modules that tag Eventful will be automatically included. + +Watch-Event will also check the local directory for event sources. + + +|Name |Synopsis | +|--------------------------------------------------------|----------------------------------------------| +|[@CommandNotFound](/docs/CommandNotFound-EventSource.md)|Sends events when a command is not found.
| +|[@Delay](/docs/Delay-EventSource.md) |Send an event after a delay.
| +|[@Event](/docs/Event-EventSource.md) |Watches for new events.
| +|[@FileChange](/docs/FileChange-EventSource.md) |Watches for File Changes.
| +|[@HttpResponse](/docs/HttpResponse-EventSource.md) |Sends events on HTTP Responses.
| +|[@Job](/docs/Job-EventSource.md) |Watches a PowerShell Job's State.
| +|[@LocationChanged](/docs/LocationChanged-EventSource.md)|Sends events when the directory changes.
| +|[@ModuleChanged](/docs/ModuleChanged-EventSource.md) |Watches for Module loads and unloads.
| +|[@PowerShellAsync](/docs/PowerShellAsync-EventSource.md)|Runs PowerShell asynchronously
| +|[@Process](/docs/Process-EventSource.md) |Watches a process.
| +|[@Repeat](/docs/Repeat-EventSource.md) |Send events on repeat.
| +|[@Time](/docs/Time-EventSource.md) |Sends an event at a specific time.
| +|[@UDP](/docs/UDP-EventSource.md) |Signals on UDP
| +|[@VariableSet](/docs/VariableSet-EventSource.md) |Watches for variable sets.
| + + + + + diff --git a/EventSources/README.ps.md b/EventSources/README.ps.md new file mode 100644 index 0000000..5b3d9ea --- /dev/null +++ b/EventSources/README.ps.md @@ -0,0 +1,21 @@ +This directory contains the built-in EventSources in Eventful. + +_Technically speaking_, EventSources can exist in any directory, as long as they are named liked `@*.ps1` and match `^@\w`. + +Event sources within Eventful or modules that tag Eventful will be automatically included. + +Watch-Event will also check the local directory for event sources. + +~~~PipeScript{ + $imported = Import-Module ../ -Global -PassThru + + [PSCustomObject]@{ + Table = Get-EventSource | + .Name { + "[$($_.Name -replace '\.ps1$')](/docs/$($_.Name -replace '^@' -replace '\.ps1$')-EventSource.md)" + } .Synopsis + } +} +~~~ + + diff --git a/Eventful.GithubWorkflow.psdevops.ps1 b/Eventful.GithubWorkflow.psdevops.ps1 index c627594..c2a76d3 100644 --- a/Eventful.GithubWorkflow.psdevops.ps1 +++ b/Eventful.GithubWorkflow.psdevops.ps1 @@ -2,9 +2,11 @@ Import-BuildStep -Module Eventful New-GitHubWorkflow -Name "Analyze, Test, Tag, and Publish" -On Push, PullRequest, Demand -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, BuildEventful -Environment @{ NoCoverage = $true -}| - Set-Content .\.github\workflows\TestAndPublish.yml -Encoding UTF8 -PassThru +} -OutputPath ( + Join-Path $PSScriptRoot .github\workflows\TestAndPublish.yml +) -New-GitHubWorkflow -On Issue, Demand -Job RunGitPub -Name OnIssueChanged | - Set-Content (Join-Path $PSScriptRoot .github\workflows\OnIssue.yml) -Encoding UTF8 -PassThru +New-GitHubWorkflow -On Issue, Demand -Job RunGitPub -Name OnIssueChanged -OutputPath ( + Join-Path $PSScriptRoot .github\workflows\OnIssue.yml +) diff --git a/Eventful.PSSVG.ps1 b/Eventful.PSSVG.ps1 index 56df35b..a720c68 100644 --- a/Eventful.PSSVG.ps1 +++ b/Eventful.PSSVG.ps1 @@ -6,7 +6,7 @@ if (-not (Test-Path $assetsPath)) { $null = New-Item -ItemType Directory -path $assetsPath -Force } = -content $( - $commonParameters = @{ + $commonParameters = [Ordered]@{ Fill = '#4488FF' Stroke = 'black' StrokeWidth = '0.05' diff --git a/Eventful.psd1 b/Eventful.psd1 index 52d14a0..f644a3f 100644 --- a/Eventful.psd1 +++ b/Eventful.psd1 @@ -1,10 +1,10 @@ @{ RootModule = 'Eventful.psm1' - Description = 'Easy Eventful Asynchronous Scripting with PowerShell' - ModuleVersion = '0.1.7' + Description = 'Easy Eventful PowerShell' + ModuleVersion = '0.1.8' GUID = 'f4d780da-be78-49c6-921a-436e053cb97c' Author = 'James Brundage' - Copyright = '2021 Start-Automating' + Copyright = '2021-2023 Start-Automating' FormatsToProcess = 'Eventful.format.ps1xml' TypesToProcess = 'Eventful.types.ps1xml' AliasesToExport = '*' @@ -16,32 +16,45 @@ Tags = 'Eventful', 'Events' ReleaseNotes = @' -## 0.1.7 +## Eventful 0.1.8: + +* Eventful Supports Sponsorship (#25) +* New Commands! + * Import-Event (#28) + * Export-Event (#27) +* Send-Event can now send -EventArguments and -MessageData (#26) +* Watch-Event now supports -MaxTriggerCount and -MessageData (#29) +* Simplifying event source registration (any `@*` script or function) (#30) +* Making one-time event sources more efficient (#31) + +--- + +## Eventful 0.1.7: * Adding On@CommandNotFound event source (Fixes #11) * Watch-Event now allows eventsources -recursively (Fixes #15) --- -## 0.1.6 +## Eventful 0.1.6 * Adding LocationChanged event source (Fixes #12) --- -## 0.1.5 +## Eventful 0.1.5 * Adding On@Event (#2) * Send-Event support for piping existing events (#4) * Adding /docs (#5) --- -## 0.1.4 +## Eventful 0.1.4 * Module Rebranded to Eventful. * Get-EventHandler added --- -## 0.1.3 +## Eventful 0.1.3 New Event Source: * VariableSet @@ -52,7 +65,7 @@ Bugfix: On@Repeat now actually starts it's timer. --- -## 0.1.2 +## Eventful 0.1.2 New Event Source: * UDP @@ -60,7 +73,7 @@ PowerShellAsync Event Source now allows for a -Parameter dictionaries. --- -## 0.1.1 +## Eventful 0.1.1 New Event Sources: * HTTPResponse * PowerShellAsync @@ -72,7 +85,10 @@ New Event Source Capabilities: Event Sources can now return an InitializeEvent property or provide a ComponentModel.InitializationEvent attribute. This will be called directly after the subscription is created, so as to avoid signalling too soon. -## 0.1 +--- + +## Eventful 0.1 + Initial Module Release. Fun simple event syntax (e.g. on mysignal {"do this"} or on delay "00:00:01" {"do that"}) @@ -82,19 +98,8 @@ Better pipelining support for Sending events. '@ } - - Eventful = @{ - 'Time' = '@Time.ps1' - 'Delay' = '@Delay.ps1' - 'Process' = 'EventSources/@Process.ps1' - 'ModuleChanged' = 'EventSources/@ModuleChanged.ps1' - 'Job' = 'EventSources/@Job.ps1' - 'PowerShellAsync' = 'EventSources/@PowerShellAsync.ps1' - 'HttpResponse' = 'EventSources/@HttpResponse.ps1' - 'VariableSet' = 'EventSources/@VariableSet.ps1' - 'UDP' = 'EventSources/@UDP.ps1' - 'Event' = 'EventSources/@Event.ps1' - 'LocationChanged' = 'EventSources/@LocationChanged.ps1' + CommandTypes = @{ + EventSource = '^\@\w' } } } diff --git a/Eventful.tests.ps1 b/Eventful.tests.ps1 index af49987..67891af 100644 --- a/Eventful.tests.ps1 +++ b/Eventful.tests.ps1 @@ -55,13 +55,13 @@ describe Eventful { } it 'Can get a signal when a job finishes' { $global:JobsIsDone = $false - $j = Start-Job -ScriptBlock { Start-Sleep -Milliseconds 500; "done" } + $j = Start-Job -ScriptBlock { Start-Sleep -Milliseconds 750; "done" } $j| On@Job -Then { $global:JobsIsDone = $true } do { - Start-Sleep -Milliseconds 750 + Start-Sleep -Milliseconds 1000 } while ($j.JobStateInfo.State -ne 'Completed') Start-Sleep -Milliseconds 250 @@ -85,9 +85,9 @@ describe Eventful { } it 'Can receive results from event subscriptions' { - on delay "00:00:00.1" -Then {1} # Signal in a tenth of a second. + on@repeat -interval "00:00:00.1" -Then {1} # Signal every tenth of a second. Start-Sleep -Milliseconds 250 - $receivedResults = @(Get-EventSource -Name Delay -Subscription | Receive-Event) + $receivedResults = @(Get-EventSource -Name Repeat -Subscription | Receive-Event) $receivedResults.Length | Should -BeGreaterOrEqual 1 } diff --git a/Export-Event.ps1 b/Export-Event.ps1 new file mode 100644 index 0000000..8be68b9 --- /dev/null +++ b/Export-Event.ps1 @@ -0,0 +1,109 @@ +function Export-Event +{ + <# + .Synopsis + Exports events + .Description + Exports events to a file for long term storage. + .Example + Export-Event -OutputPath .\Events.clixml -SourceIdentifier * + .LINK + Import-Event + .Link + Receive-Event + #> + param( + # The Output Path for the exported events. + [ValidateScript({ + $extension = @($_ -split '\.')[-1] + $exporter = $ExecutionContext.SessionState.InvokeCommand.GetCommand( + "Export-$Extension", + "Function,Alias,Cmdlet" + ) + if (-not $exporter) { + throw "Export-$Extension does not exist. Cannot export .$Extension" + } + return $true + })] + [Parameter(Mandatory)] + [string] + $OutputPath, + + # The source identifier. If not provided, all unhandled events will be exported. + [Parameter(ValueFromPipelineByPropertyName)] + [string[]] + $SourceIdentifier, + + # If provided, will return the first N events + [int] + $First, + + # If provided, will skip the first N events. + [int] + $Skip, + + # If set, will overwrite existing files. + # If not set, existing files will be read in, and events will be appeneded. + [switch] + $Force + ) + + begin { + $accumulatedEvents = [Collections.Queue]::new() + } + process { + if ($_ -is [Management.Automation.PSEvent]) { + $accumulatedEvents.Enqueue($_) + return + } + + $receiveSplat = @{} + $PSBoundParameters + $receiveSplat.Remove('OutputPath') + $receiveSplat.Remove('Force') + if (-not $receiveSplat.SourceIdentifier) { + $receiveSplat.SourceIdentifier = '*' + } + foreach ($eventInfo in Receive-Event @receiveSplat) { + $accumulatedEvents.Enqueue($eventInfo) + } + + if (-not $accumulatedEvents.Count) { + Write-Verbose "No Events Received. Nothing to export." + return + } + } + + + end { + $outputPathExists = Test-Path $OutputPath + + # try to find an exporter + $exporter = $ExecutionContext.SessionState.InvokeCommand.GetCommand( + # (by looking for any Export-Command that shares a name with the extension) + "Export-$(@($OutputPath -split '\.')[-1])", + 'Function,Alias,Cmdlet' + ) + + if (-not $exporter) { + Write-Error "No Exporter found for $OutputPath" + return + } + + if ($outputPathExists -and -not $force) { + $importer = $ExecutionContext.SessionState.InvokeCommand.GetCommand( + # (by looking for any Import-Command that shares a name with the extension) + "Import-$(@($OutputPath -split '\.')[-1])", + 'Function,Alias,Cmdlet' + ) + $receivedEvents = @() + @(& $importer $OutputPath) + $accumulatedEvents.ToArray() + } else { + $receivedEvents = $accumulatedEvents.ToArray() + } + + $receivedEvents | & $exporter $OutputPath + + if ($?) { + Get-Item $OutputPath + } + } +} diff --git a/Get-EventSource.ps1 b/Get-EventSource.ps1 index 9cf0a67..b6a7684 100644 --- a/Get-EventSource.ps1 +++ b/Get-EventSource.ps1 @@ -46,8 +46,7 @@ ) begin { #region Discover Event Sources - $atFunctions = $ExecutionContext.SessionState.InvokeCommand.GetCommands('@*', 'Function',$true)| - Where-Object { $_.Value -is [ScriptBlock] } + $atFunctions = $ExecutionContext.SessionState.InvokeCommand.GetCommands('@*', 'Function',$true) -match '^@\w' # Save a pointer to the method for terseness and speed. $getCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand @@ -66,13 +65,12 @@ $atScripts = $lookInDirectory | Get-Item | - Get-ChildItem -Filter '@*.ps1' | + Get-ChildItem -Filter '@*.ps1' -Recurse | & { process { + if ($_.Name -notmatch '^\@\w') { return } $getCmd.Invoke($_.Fullname,'ExternalScript') } } - - # If we had a module, and we still don't have a match, we'll look for extensions. $loadedModules = @(Get-Module) @@ -80,16 +78,17 @@ if ($loadedModules -notcontains $myInv.MyCommand.Module) { $loadedModules = @($myInv.MyCommand.Module) + $loadedModules } + $myModuleName = $myInv.MyCommand.Module.Name $extendedCommands = foreach ($loadedModule in $loadedModules) { # Walk over all modules. if ( # If the module has PrivateData keyed to this module - $loadedModule.PrivateData.($myInv.MyCommand.Module.Name) + $loadedModule.PrivateData.$myModuleName ) { # Determine the root of the module with private data. $thisModuleRoot = [IO.Path]::GetDirectoryName($loadedModule.Path) # and get the extension data - $extensionData = $loadedModule.PrivateData.($myInv.MyCommand.Module.Name) + $extensionData = $loadedModule.PrivateData.$myModuleName if ($extensionData -is [Hashtable]) { # If it was a hashtable foreach ($ed in $extensionData.GetEnumerator()) { # walk each key @@ -108,6 +107,13 @@ } } } + elseif ($loadedModule.Tags -contains $myModuleName) { + foreach ($matchingFile in @(Get-ChildItem (Split-Path $loadedModule.Path) -Recurse) -match '\@\w' -match '\.ps1$') { + if ($matchingFile.Name -match '^\@\w' ) { + $getCmd.Invoke($matchingFile.FullName, 'ExternalScript') + } + } + } } $allSources = @() + $atFunctions + $atScripts + $extendedCommands diff --git a/GitHub/Jobs/BuildEventful.psd1 b/GitHub/Jobs/BuildEventful.psd1 new file mode 100644 index 0000000..82a1fa6 --- /dev/null +++ b/GitHub/Jobs/BuildEventful.psd1 @@ -0,0 +1,23 @@ +@{ + "runs-on" = "ubuntu-latest" + if = '${{ success() }}' + steps = @( + @{ + name = 'Check out repository' + uses = 'actions/checkout@v2' + }, + @{ + name = 'GitLogger' + uses = 'GitLogging/GitLoggerAction@main' + id = 'GitLogger' + }, + @{ + name = 'Use PSSVG Action' + uses = 'StartAutomating/PSSVG@main' + id = 'PSSVG' + }, + 'RunPipeScript', + 'RunEZOut', + 'RunHelpOut' + ) +} \ No newline at end of file diff --git a/Import-Event.ps1 b/Import-Event.ps1 new file mode 100644 index 0000000..470489a --- /dev/null +++ b/Import-Event.ps1 @@ -0,0 +1,62 @@ +function Import-Event +{ + <# + .SYNOPSIS + Imports Events + .DESCRIPTION + Imports Events from a file on disk. + .EXAMPLE + Import-Event .\Events.clixml + .LINK + Export-Event + #> + param( + # The input path. This file should be created using Export-Event + [ValidateScript({ + $extension = @($_ -split '\.')[-1] + $importer = $ExecutionContext.SessionState.InvokeCommand.GetCommand( + "Import-$Extension", + "Function,Alias,Cmdlet" + ) + if (-not $importer) { + throw "Import-$Extension does not exist. Cannot import .$Extension" + } + return $true + })] + [Parameter(Mandatory,ValueFromPipelineByPropertyName)] + [Alias('Fullname')] + [string] + $InputPath, + + # If set, will resend events. + # Only events sent with New-Event or Send-Event will be resent. + [Alias('Replay')] + [switch] + $Resend + ) + + process { + if (-not (Test-Path $InputPath)) { + return + } + + $extension = @($InputPath -split '\.')[-1] + $importer = $ExecutionContext.SessionState.InvokeCommand.GetCommand( + "Import-$Extension", + "Function,Alias,Cmdlet" + ) + + if ($resend) { + & $importer $inputPath | + & { process { + $evt = $_ + if ($evt.SourceIdentifier) { + $evt | Send-Event + } + $evt + } } + } else { + & $importer $inputPath + } + } +} diff --git a/README.md b/README.md index 18a126b..f7ee240 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ -Easy Eventful Asynchronous Scripting with PowerShell +Easy Eventful PowerShell ---------------- ### Getting Started with Eventful -Eventful is a PowerShell module that helps you use events to script asynchronously. +Eventful is a PowerShell module that helps you script asynchronously. It gives you an easy syntax to describe events handlers in PowerShell, and provides a platform to build custom event sources. diff --git a/Send-Event.ps1 b/Send-Event.ps1 index 0ffac4d..a6c19d3 100644 --- a/Send-Event.ps1 +++ b/Send-Event.ps1 @@ -20,12 +20,12 @@ [OutputType([Nullable],[Management.Automation.PSEventArgs])] param( # The SourceIdentifier - [Parameter(Mandatory,Position=0)] + [Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)] [string[]] $SourceIdentifier, # The message data - [Parameter(ValueFromPipeline,Position=1)] + [Parameter(ValueFromPipeline,Position=1,ValueFromPipelineByPropertyName)] [PSObject] $MessageData, @@ -36,9 +36,9 @@ # The event arguments. [Parameter(ValueFromPipelineByPropertyName,Position=3)] - [Alias('SourceEventArgs')] + [Alias('SourceEventArgs','EventArgs')] [PSObject] - $EventArgs, + $EventArguments, # If set, will output the created event. [Parameter(ValueFromPipelineByPropertyName)] @@ -53,6 +53,7 @@ } process { #region Map New-Event Parameters + $myParameters = @{} + $PSBoundParameters $newEventParams = @{} + $PSBoundParameters # Copy bound parameters. foreach ($k in @($newEventParams.Keys)) { if (-not $newEvent.Parameters[$k]) { # If a parameter isn't for New-Event diff --git a/Understanding_Event_Sources.md b/Understanding_Event_Sources.md index 6181384..4f90f66 100644 --- a/Understanding_Event_Sources.md +++ b/Understanding_Event_Sources.md @@ -19,7 +19,7 @@ Event sources can be found a few places: * In any function whose name starts with @ * In the directory where Watch-Event is defined * In the module root where Watch-Event is defined -* In an .OnQ [Hashtable] within a module manifest's private data +* In an .Eventful [Hashtable] within a module manifest's private data You can see the event sources currently available with: diff --git a/Watch-Event.ps1 b/Watch-Event.ps1 index 4f70ac5..c983c37 100644 --- a/Watch-Event.ps1 +++ b/Watch-Event.ps1 @@ -117,7 +117,6 @@ } else { return $atFunction } - } @@ -125,7 +124,10 @@ $atFile = "@$($invocationName).ps1" # This could be in a few places: the current directory first, foreach ($foundFile in ($pwd, $myRoot | - Get-ChildItem -Recurse -Filter $atFile)) { + Get-ChildItem -Recurse | + & { process { + if ($_.Name -eq $atFile) { $_ } + } })) { $foundCmd = $getCmd.Invoke($foundFile.FullName, 'ExternalScript') if ($foundCmd) { return $foundCmd} @@ -171,6 +173,13 @@ } } } + elseif ($loadedModule.Tags -contains $myModuleName) { + foreach ($matchingFile in @(Get-ChildItem (Split-Path $loadedModule.Path) -Recurse) -match '\@\w' -match '\.ps1$') { + if ($matchingFile.Name -eq $atFile) { + return $getCmd.Invoke($matchingFile.FullName, 'ExternalScript') + } + } + } } } @@ -235,13 +244,16 @@ #endregion Find the Event Source and Map Dynamic Parameters - #region Add Common Parameters + + #region Optionally Add Source Identifier # If we don't have an Event Source at this point and we haven't already, if (-not $eventSource -and -not $SourceIDParameterCreated) { # add the SourceIdentifier parameter. . $addSourceIdParameter } + #endregion Optionally Add Source Identifier + #region Optionally Add InputObject Parameter # Also, if we don't have an event source if (-not $eventSource) { # then we can add an InputObject parameter. @@ -254,27 +266,47 @@ ) } + #endregion Optionally Add InputObject Parameter - # All calls will always have two additional parameters: - $maxPosition++ + #region Add Common Parameters + # All calls will always have two additional parameters: $thenParam = [Management.Automation.ParameterAttribute]::new() $thenParam.Mandatory = $false #* [ScriptBlock]$then - $thenParam.Position = $maxPosition + $thenParam.Position = ++$maxPosition $thenActionAlias = [Management.Automation.AliasAttribute]::new("Action") $DynamicParameters.Add("Then", [Management.Automation.RuntimeDefinedParameter]::new( "Then", [ScriptBlock], @($thenParam, $thenActionAlias) ) ) - $maxPosition++ + $WhenParam = [Management.Automation.ParameterAttribute]::new() - $whenParam.Position = $maxPosition #* [ScriptBlock]$then + $whenParam.Position = ++$maxPosition #* [ScriptBlock]$when $DynamicParameters.Add("When", [Management.Automation.RuntimeDefinedParameter]::new( "When", [ScriptBlock], $WhenParam ) ) - + + $MessageDataParam = [Management.Automation.ParameterAttribute]::new() + $MessageDataParam.Position = ++$maxPosition #* [ScriptBlock]$when + $DynamicParameters.Add("MessageData", + [Management.Automation.RuntimeDefinedParameter]::new( + "MessageData", [PSObject], $MessageDataParam + ) + ) + + $maxTriggerParam = [Management.Automation.ParameterAttribute]::new() + $maxTriggerParam.Position = ++$maxPosition #* [int]$MaxTriggerCount + $DynamicParameters.Add("MaxTriggerCount", + [Management.Automation.RuntimeDefinedParameter]::new( + "MaxTriggerCount", [int], @( + $maxTriggerParam, + [Management.Automation.AliasAttribute]::new("Max"), + [Management.Automation.AliasAttribute]::new("Count") + ) + ) + ) #endregion Add Common Parameters @@ -304,12 +336,20 @@ $($parameterCopy | Out-String) #region Run Event Source and Map Parameters if ($eventSource) { # If we have an Event Source, now's the time to run it. $eventSourceParameter = [Ordered]@{} + $PSBoundParameters # Copy whatever parameters we have - $eventSourceParameter.Remove('Then') # and remove -Then, - $eventSourceParameter.Remove('When') # -When, - $eventSourceParameter.Remove('SourceIdentifier') # and -SourceIdentifier. + foreach ($toRemove in 'Then','When','SourceIdentifier','MessageData','MaxTriggerCount') { + $eventSourceParameter.Remove($toRemove) + } $eventSourceOutput = & $eventSource @eventSourceParameter # Then run the generator. $null = $PSBoundParameters.Remove('SourceIdentifier') + if ($eventSourceOutput.MessageData) { + $registerParams['MessageData'] = $eventSourceOutput.MessageData + } + $eventSourceMaxTriggerCount = $eventSourceOutput.MaxTriggerCount,$eventSourceOutput.Max,$eventSourceOutput.TriggerCount -as [int[]] -gt 0 + + if ($eventSourceMaxTriggerCount) { + $registerParams['MaxTriggerCount'] = $eventSourceMaxTriggerCount[0] + } if (-not $eventSourceOutput) { # If it didn't output, # we're gonna assume it it's gonna by signal by name. @@ -394,7 +434,7 @@ $($parameterCopy | Out-String) if ($When) { # If -When was provided if ($when -is [ScriptBlock]) { # and it was a script - # Rewrite -Then to include -When. + # Rewrite -Then to include -When (this prevents debugging). # Run -When in a subexpression so it can return from the event handler (not itself) $then = [ScriptBlock]::Create(@" `$shouldHandle = `$( @@ -411,6 +451,16 @@ $then } #endregion Handle When and Then + #region Handle MaxTriggerCount and MessageData + if ($parameterCopy['MaxTriggerCount']) { + $registerParams['MaxTriggerCount'] = $parameterCopy['MaxTriggerCount'] + } + + if ($parameterCopy['MessageData']) { + $registerParams['MessageData'] = $parameterCopy['MessageData'] + } + #endregion + #region Subscribe to Event # Now we create the event subscription. diff --git a/docs/Assets/Eventful.svg b/docs/Assets/Eventful.svg index 5c65d8f..677843d 100644 --- a/docs/Assets/Eventful.svg +++ b/docs/Assets/Eventful.svg @@ -3,8 +3,8 @@ - - + + @ eventful diff --git a/docs/Clear-EventSource-EventSource.md b/docs/Clear-EventSource-EventSource.md deleted file mode 100644 index b122686..0000000 --- a/docs/Clear-EventSource-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Clear-EventSource.ps1 - - - diff --git a/docs/Clear-EventSource.md b/docs/Clear-EventSource.md index 026ed5e..12507c2 100644 --- a/docs/Clear-EventSource.md +++ b/docs/Clear-EventSource.md @@ -1,28 +1,47 @@ - Clear-EventSource ----------------- + + + + ### Synopsis Clears event source subscriptions + + --- + + ### Description Clears any active subscriptions for any event source. + + --- + + ### Related Links * [Get-EventSource](Get-EventSource.md) + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell Clear-EventSource ``` + + --- + + ### Parameters #### **Name** @@ -30,41 +49,44 @@ The name of the event source. -> **Type**: ```[String[]]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|false |1 |true (ByPropertyName)| ---- #### **WhatIf** -WhatIf is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. -WhatIf is used to see what would happen, or return operations without executing them #### **Confirm** -Confirm is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. -Confirm is used to -Confirm each operation. - + If you pass ```-Confirm:$false``` you will not be prompted. - - + + If the command sets a ```[ConfirmImpact("Medium")]``` which is lower than ```$confirmImpactPreference```, you will not be prompted unless -Confirm is passed. + + --- + + ### Outputs * [Nullable](https://learn.microsoft.com/en-us/dotnet/api/System.Nullable) + + --- + + ### Syntax ```PowerShell Clear-EventSource [[-Name] ] [-WhatIf] [-Confirm] [] ``` ---- - - diff --git a/docs/CommandNotFound-EventSource.md b/docs/CommandNotFound-EventSource.md index ab3760e..c463e89 100644 --- a/docs/CommandNotFound-EventSource.md +++ b/docs/CommandNotFound-EventSource.md @@ -1,17 +1,28 @@ - EventSources/@CommandNotFound.ps1 --------------------------------- + + + + ### Synopsis Sends events when a command is not found. + + --- + + ### Description Sends events when a command is not found. Handling this event can resolve any unknown command. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell @@ -23,13 +34,12 @@ On@CommandNotFound On@CommandNotFound -Then { $event | Out-Host } ``` + + --- + + ### Syntax ```PowerShell EventSources/@CommandNotFound.ps1 [] ``` ---- - - - - diff --git a/docs/Delay-EventSource.md b/docs/Delay-EventSource.md index 937bd82..4b170d9 100644 --- a/docs/Delay-EventSource.md +++ b/docs/Delay-EventSource.md @@ -1,22 +1,37 @@ +EventSources/@Delay.ps1 +----------------------- + + + -@Delay.ps1 ----------- ### Synopsis Send an event after a delay. + + --- + + ### Description Send an event after waiting an arbitrary [Timespan] + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell On Delay "00:00:01" -Then { "In a second!" | Out-Host } ``` + + --- + + ### Parameters #### **Wait** @@ -24,22 +39,21 @@ The amount of time to wait -> **Type**: ```[TimeSpan]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases | +|------------|--------|--------|---------------------|------------| +|`[TimeSpan]`|true |1 |true (ByPropertyName)|Delay
In| + + --- + + ### Syntax ```PowerShell -@Delay.ps1 [-Wait] [] +EventSources/@Delay.ps1 [-Wait] [] ``` ---- - - - diff --git a/docs/Event-EventSource.md b/docs/Event-EventSource.md index 618cdec..505d3f8 100644 --- a/docs/Event-EventSource.md +++ b/docs/Event-EventSource.md @@ -1,23 +1,29 @@ - EventSources/@Event.ps1 ----------------------- + + + + ### Synopsis Watches for new events. + + --- + + ### Description Watches for any new events. Subscribing to this event will preempt all other events. + + --- + + ### Syntax ```PowerShell EventSources/@Event.ps1 [] ``` ---- - - - - diff --git a/docs/EventFul.EventHandler.format-EventSource.md b/docs/EventFul.EventHandler.format-EventSource.md deleted file mode 100644 index 3186a9c..0000000 --- a/docs/EventFul.EventHandler.format-EventSource.md +++ /dev/null @@ -1,5 +0,0 @@ -EventFul.EventHandler.format.ps1 - - - - diff --git a/docs/Eventful.EventSource.format-EventSource.md b/docs/Eventful.EventSource.format-EventSource.md deleted file mode 100644 index 62d0492..0000000 --- a/docs/Eventful.EventSource.format-EventSource.md +++ /dev/null @@ -1,5 +0,0 @@ -Eventful.EventSource.format.ps1 - - - - diff --git a/docs/Eventful.GithubWorkflow.psdevops-EventSource.md b/docs/Eventful.GithubWorkflow.psdevops-EventSource.md deleted file mode 100644 index d3b34dd..0000000 --- a/docs/Eventful.GithubWorkflow.psdevops-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Eventful.GithubWorkflow.psdevops.ps1 - - - diff --git a/docs/Eventful.HelpOut-EventSource.md b/docs/Eventful.HelpOut-EventSource.md deleted file mode 100644 index 566bbc5..0000000 --- a/docs/Eventful.HelpOut-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Eventful.HelpOut.ps1 - - - diff --git a/docs/Eventful.PSSVG-EventSource.md b/docs/Eventful.PSSVG-EventSource.md deleted file mode 100644 index 6a68614..0000000 --- a/docs/Eventful.PSSVG-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Eventful.PSSVG.ps1 - - - diff --git a/docs/Eventful.ezout-EventSource.md b/docs/Eventful.ezout-EventSource.md deleted file mode 100644 index 6cb00fe..0000000 --- a/docs/Eventful.ezout-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Eventful.ezout.ps1 - - - diff --git a/docs/Eventful.tests-EventSource.md b/docs/Eventful.tests-EventSource.md deleted file mode 100644 index fe3fd36..0000000 --- a/docs/Eventful.tests-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Eventful.tests.ps1 - - - diff --git a/docs/Export-Event.md b/docs/Export-Event.md new file mode 100644 index 0000000..aa9fc37 --- /dev/null +++ b/docs/Export-Event.md @@ -0,0 +1,134 @@ +Export-Event +------------ + + + + +### Synopsis +Exports events + + + +--- + + +### Description + +Exports events to a file for long term storage. + + + +--- + + +### Related Links +* [Import-Event](Import-Event.md) + + + +* [Receive-Event](Receive-Event.md) + + + + + +--- + + +### Examples +#### EXAMPLE 1 +```PowerShell +Export-Event -OutputPath .\Events.clixml -SourceIdentifier * +``` + + + +--- + + +### Parameters +#### **OutputPath** + +The Output Path for the exported events. + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[String]`|true |1 |false | + + + +#### **SourceIdentifier** + +The source identifier. If not provided, all unhandled events will be exported. + + + + + + +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|false |2 |true (ByPropertyName)| + + + +#### **First** + +If provided, will return the first N events + + + + + + +|Type |Required|Position|PipelineInput| +|---------|--------|--------|-------------| +|`[Int32]`|false |3 |false | + + + +#### **Skip** + +If provided, will skip the first N events. + + + + + + +|Type |Required|Position|PipelineInput| +|---------|--------|--------|-------------| +|`[Int32]`|false |4 |false | + + + +#### **Force** + +If set, will overwrite existing files. +If not set, existing files will be read in, and events will be appeneded. + + + + + + +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | + + + + + +--- + + +### Syntax +```PowerShell +Export-Event [-OutputPath] [[-SourceIdentifier] ] [[-First] ] [[-Skip] ] [-Force] [] +``` diff --git a/docs/FileChange-EventSource.md b/docs/FileChange-EventSource.md index 8af8080..8c9bf56 100644 --- a/docs/FileChange-EventSource.md +++ b/docs/FileChange-EventSource.md @@ -1,10 +1,17 @@ +EventSources/@FileChange.ps1 +---------------------------- + + + -@FileChange.ps1 ---------------- ### Synopsis Watches for File Changes. + + --- + + ### Description Uses the [IO.FileSystemWatcher] to watch for changes to files. @@ -12,7 +19,11 @@ Uses the [IO.FileSystemWatcher] to watch for changes to files. Because some applications and frameworks write to files differently, you may see more than one event for a given change. + + --- + + ### Parameters #### **FilePath** @@ -20,34 +31,30 @@ The path to the file or directory -> **Type**: ```[String]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases | +|----------|--------|--------|---------------------|--------| +|`[String]`|false |1 |true (ByPropertyName)|Fullname| ---- #### **FileFilter** A wildcard filter describing the names of files to watch -> **Type**: ```[String]``` -> **Required**: false -> **Position**: 2 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[String]`|false |2 |true (ByPropertyName)| ---- #### **NotifyFilter** A notify filter describing the file changes that should raise events. @@ -67,34 +74,30 @@ Valid Values: -> **Type**: ```[NotifyFilters[]]``` -> **Required**: false -> **Position**: 3 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|-------------------|--------|--------|---------------------| +|`[NotifyFilters[]]`|false |3 |true (ByPropertyName)| ---- #### **Recurse** If set, will include subdirectories in the watcher. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput|Aliases | +|----------|--------|--------|-------------|---------------------------------------------| +|`[Switch]`|false |named |false |InludeSubsdirectory
InludeSubsdirectories| ---- #### **EventName** The names of the file change events to watch. @@ -111,22 +114,21 @@ Valid Values: -> **Type**: ```[String[]]``` -> **Required**: false -> **Position**: 4 -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[String[]]`|false |4 |false | + + --- + + ### Syntax ```PowerShell -@FileChange.ps1 [[-FilePath] ] [[-FileFilter] ] [[-NotifyFilter] {FileName | DirectoryName | Attributes | Size | LastWrite | LastAccess | CreationTime | Security}] [-Recurse] [[-EventName] ] [] +EventSources/@FileChange.ps1 [[-FilePath] ] [[-FileFilter] ] [[-NotifyFilter] {FileName | DirectoryName | Attributes | Size | LastWrite | LastAccess | CreationTime | Security}] [-Recurse] [[-EventName] ] [] ``` ---- - - - diff --git a/docs/Get-EventHandler-EventSource.md b/docs/Get-EventHandler-EventSource.md deleted file mode 100644 index cbcf33d..0000000 --- a/docs/Get-EventHandler-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Get-EventHandler.ps1 - - - diff --git a/docs/Get-EventHandler.md b/docs/Get-EventHandler.md index ac759f6..a1bf095 100644 --- a/docs/Get-EventHandler.md +++ b/docs/Get-EventHandler.md @@ -1,10 +1,17 @@ - Get-EventHandler ---------------- + + + + ### Synopsis Gets Event Handlers + + --- + + ### Description Gets files that act as Event Handlers. @@ -14,7 +21,11 @@ These files can be named a few ways: * On_[EventName].ps1 / [EventName].handler.ps1 (These handle a single event) * [Name].handlers.ps1 / [Name].events.ps1 (These handle multiple events) + + --- + + ### Parameters #### **HandlerPath** @@ -22,21 +33,21 @@ The path to the handler file(s) -> **Type**: ```[String[]]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|false |1 |true (ByPropertyName)| + + --- + + ### Syntax ```PowerShell Get-EventHandler [[-HandlerPath] ] [] ``` ---- - - diff --git a/docs/Get-EventSource-EventSource.md b/docs/Get-EventSource-EventSource.md deleted file mode 100644 index 1f89289..0000000 --- a/docs/Get-EventSource-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Get-EventSource.ps1 - - - diff --git a/docs/Get-EventSource.md b/docs/Get-EventSource.md index 52db982..372299f 100644 --- a/docs/Get-EventSource.md +++ b/docs/Get-EventSource.md @@ -1,10 +1,17 @@ - Get-EventSource --------------- + + + + ### Synopsis Gets Event Sources + + --- + + ### Description Gets Event Sources. @@ -16,13 +23,21 @@ Event sources can be implemented in: * An in-memory scriptblock variable starting with @ * A module command referenced within a PrivateData.OnQ section of the module manifest. + + --- + + ### Related Links * [Watch-Event](Watch-Event.md) + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell @@ -34,7 +49,11 @@ Get-EventSource Get-EventSource -Subscription ``` + + --- + + ### Parameters #### **Name** @@ -42,68 +61,65 @@ The name of the event source. -> **Type**: ```[String[]]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|false |1 |true (ByPropertyName)| ---- #### **Subscription** If set, will get subscriptions related to event sources. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[Switch]`|false |named |true (ByPropertyName)| ---- #### **SourceObject** If set, will get source objects from the subscriptions related to event sources. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[Switch]`|false |named |true (ByPropertyName)| ---- #### **Help** If set, will get full help for each event source. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[Switch]`|false |named |true (ByPropertyName)| + + --- + + ### Outputs * Eventful.EventSource @@ -119,11 +135,12 @@ If set, will get full help for each event source. + + --- + + ### Syntax ```PowerShell Get-EventSource [[-Name] ] [-Subscription] [-SourceObject] [-Help] [] ``` ---- - - diff --git a/docs/HttpResponse-EventSource.md b/docs/HttpResponse-EventSource.md index d74194d..b6ca960 100644 --- a/docs/HttpResponse-EventSource.md +++ b/docs/HttpResponse-EventSource.md @@ -1,10 +1,17 @@ - EventSources/@HttpResponse.ps1 ------------------------------ + + + + ### Synopsis Sends events on HTTP Responses. + + --- + + ### Description Sends HTTP requests and signals on Responses @@ -14,7 +21,11 @@ Event MessageData will contain the response, with two additional properties: * .ResponseBytes * .ResponseContent + + --- + + ### Parameters #### **Uri** @@ -22,17 +33,15 @@ The Uniform Resource Identifier. -> **Type**: ```[Uri]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases| +|-------|--------|--------|---------------------|-------| +|`[Uri]`|true |1 |true (ByPropertyName)|Url | ---- #### **Method** The HTTP Method @@ -53,51 +62,45 @@ Valid Values: -> **Type**: ```[String]``` -> **Required**: false -> **Position**: 2 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[String]`|false |2 |true (ByPropertyName)| ---- #### **Header** A collection of headers to send with the request. -> **Type**: ```[IDictionary]``` -> **Required**: false -> **Position**: 3 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases| +|---------------|--------|--------|---------------------|-------| +|`[IDictionary]`|false |3 |true (ByPropertyName)|Headers| ---- #### **Body** The request body. -> **Type**: ```[PSObject]``` -> **Required**: false -> **Position**: 4 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[PSObject]`|false |4 |true (ByPropertyName)| ---- #### **PollingInterval** The polling interval. @@ -105,36 +108,32 @@ This is the minimum amount of time until you will be notified of the success or -> **Type**: ```[TimeSpan]``` -> **Required**: false -> **Position**: 4 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[TimeSpan]`|false |4 |true (ByPropertyName)| ---- #### **TransferEncoding** -> **Type**: ```[Encoding]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[Encoding]`|false |named |false | + + --- + + ### Syntax ```PowerShell EventSources/@HttpResponse.ps1 [-Uri] [[-Method] ] [[-Header] ] [[-Body] ] [[-PollingInterval] ] [-TransferEncoding ] [] ``` ---- - - - - diff --git a/docs/Import-Event.md b/docs/Import-Event.md new file mode 100644 index 0000000..647cc6d --- /dev/null +++ b/docs/Import-Event.md @@ -0,0 +1,85 @@ +Import-Event +------------ + + + + +### Synopsis +Imports Events + + + +--- + + +### Description + +Imports Events from a file on disk. + + + +--- + + +### Related Links +* [Export-Event](Export-Event.md) + + + + + +--- + + +### Examples +#### EXAMPLE 1 +```PowerShell +Import-Event .\Events.clixml +``` + + + +--- + + +### Parameters +#### **InputPath** + +The input path. This file should be created using Export-Event + + + + + + +|Type |Required|Position|PipelineInput |Aliases | +|----------|--------|--------|---------------------|--------| +|`[String]`|true |1 |true (ByPropertyName)|Fullname| + + + +#### **Resend** + +If set, will resend events. +Only events sent with New-Event or Send-Event will be resent. + + + + + + +|Type |Required|Position|PipelineInput|Aliases| +|----------|--------|--------|-------------|-------| +|`[Switch]`|false |named |false |Replay | + + + + + +--- + + +### Syntax +```PowerShell +Import-Event [-InputPath] [-Resend] [] +``` diff --git a/docs/Job-EventSource.md b/docs/Job-EventSource.md index 7018861..6484517 100644 --- a/docs/Job-EventSource.md +++ b/docs/Job-EventSource.md @@ -1,37 +1,46 @@ - EventSources/@Job.ps1 --------------------- + + + + ### Synopsis Watches a PowerShell Job's State. + + --- + + ### Description Watches a PowerShell Job's StateChange event. This will send an event when a job finishes. + + --- + + ### Parameters #### **JobID** -> **Type**: ```[Int32]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases| +|---------|--------|--------|---------------------|-------| +|`[Int32]`|true |1 |true (ByPropertyName)|ID | + + --- + + ### Syntax ```PowerShell EventSources/@Job.ps1 [-JobID] [] ``` ---- - - - - diff --git a/docs/LocationChanged-EventSource.md b/docs/LocationChanged-EventSource.md index e2371b0..bb0d30a 100644 --- a/docs/LocationChanged-EventSource.md +++ b/docs/LocationChanged-EventSource.md @@ -1,15 +1,26 @@ - EventSources/@LocationChanged.ps1 --------------------------------- + + + + ### Synopsis Sends events when the directory changes. + + --- + + ### Description Sends events when the PowerShell current directory changes. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell @@ -21,13 +32,12 @@ On@LocationChanged On@LocationChanged -Then { $event | Out-Host } ``` + + --- + + ### Syntax ```PowerShell EventSources/@LocationChanged.ps1 [] ``` ---- - - - - diff --git a/docs/ModuleChanged-EventSource.md b/docs/ModuleChanged-EventSource.md index f61aa25..6435018 100644 --- a/docs/ModuleChanged-EventSource.md +++ b/docs/ModuleChanged-EventSource.md @@ -1,10 +1,17 @@ - EventSources/@ModuleChanged.ps1 ------------------------------- + + + + ### Synopsis Watches for Module loads and unloads. + + --- + + ### Description Polls the current set of globally imported PowerShell modules. @@ -16,7 +23,11 @@ PowerShell.Module.Unloaded will be sent when one or more modules is unloaded Only one event if each will be sent per polling interval. + + --- + + ### Parameters #### **PollingInterval** @@ -24,23 +35,21 @@ The frequency to check for a module load. -> **Type**: ```[TimeSpan]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[TimeSpan]`|false |1 |false | + + --- + + ### Syntax ```PowerShell EventSources/@ModuleChanged.ps1 [[-PollingInterval] ] [] ``` ---- - - - - diff --git a/docs/PowerShellAsync-EventSource.md b/docs/PowerShellAsync-EventSource.md index e4313f8..06e7e5d 100644 --- a/docs/PowerShellAsync-EventSource.md +++ b/docs/PowerShellAsync-EventSource.md @@ -1,16 +1,27 @@ - EventSources/@PowerShellAsync.ps1 --------------------------------- + + + + ### Synopsis Runs PowerShell asynchronously + + --- + + ### Description Runs PowerShell in the background. Events are fired on the completion or failure of the PowerShell command. + + --- + + ### Parameters #### **ScriptBlock** @@ -18,74 +29,66 @@ The scripts you would like to run. Each script block will be counted as a disti -> **Type**: ```[ScriptBlock[]]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|-----------------|--------|--------|-------------| +|`[ScriptBlock[]]`|true |1 |false | ---- #### **Parameter** The named parameters passed to each script. -> **Type**: ```[IDictionary[]]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput|Aliases | +|-----------------|--------|--------|-------------|----------| +|`[IDictionary[]]`|false |named |false |Parameters| ---- #### **Runspace** If provided, will run in a specified runspace. The Runspace must already be open. -> **Type**: ```[Runspace]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[Runspace]`|false |named |false | ---- #### **RunspacePool** If provided, will run in a runspace pool. The RunspacePool must already be open. -> **Type**: ```[RunspacePool]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|----------------|--------|--------|-------------| +|`[RunspacePool]`|false |named |false | + + --- + + ### Syntax ```PowerShell EventSources/@PowerShellAsync.ps1 [-ScriptBlock] [-Parameter ] [-Runspace ] [-RunspacePool ] [] ``` ---- - - - - diff --git a/docs/Process-EventSource.md b/docs/Process-EventSource.md index e1cb5e4..1266633 100644 --- a/docs/Process-EventSource.md +++ b/docs/Process-EventSource.md @@ -1,10 +1,17 @@ - EventSources/@Process.ps1 ------------------------- + + + + ### Synopsis Watches a process. + + --- + + ### Description Watches a process. @@ -15,7 +22,11 @@ If -Output is passed, watches for process output If -Error is passed, watched for process error + + --- + + ### Parameters #### **ProcessID** @@ -23,74 +34,66 @@ The process identifier -> **Type**: ```[Int32]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases| +|---------|--------|--------|---------------------|-------| +|`[Int32]`|true |1 |true (ByPropertyName)|ID | ---- #### **Exit** If set, will watch for process exit. This is the default unless -StandardError or -StandardOutput are passed. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | ---- #### **StandardOutput** If set, will watch for new standard output. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | ---- #### **StandardError** If set, will watch for new standard erorr. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | + + --- + + ### Syntax ```PowerShell EventSources/@Process.ps1 [-ProcessID] [-Exit] [-StandardOutput] [-StandardError] [] ``` ---- - - - - diff --git a/docs/Receive-Event-EventSource.md b/docs/Receive-Event-EventSource.md deleted file mode 100644 index 1acc3ff..0000000 --- a/docs/Receive-Event-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Receive-Event.ps1 - - - diff --git a/docs/Receive-Event.md b/docs/Receive-Event.md index aded1d6..daf4ad0 100644 --- a/docs/Receive-Event.md +++ b/docs/Receive-Event.md @@ -1,15 +1,26 @@ - Receive-Event ------------- + + + + ### Synopsis Receives Events + + --- + + ### Description Receives Events and output from Event Subscriptions. + + --- + + ### Related Links * [Send-Event](Send-Event.md) @@ -19,7 +30,11 @@ Receives Events and output from Event Subscriptions. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell @@ -31,7 +46,11 @@ Get-EventSource -Subscriber | Receive-Event Receive-Event -SourceIdentifier * -First 1 # Receives the most recent event with any source identifier. ``` + + --- + + ### Parameters #### **SubscriptionID** @@ -39,85 +58,75 @@ The event subscription ID. -> **Type**: ```[Int32[]]``` -> **Required**: true -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|-----------|--------|--------|---------------------| +|`[Int32[]]`|true |named |true (ByPropertyName)| ---- #### **EventIdentifier** The event ID. -> **Type**: ```[Int32[]]``` -> **Required**: true -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|-----------|--------|--------|---------------------| +|`[Int32[]]`|true |named |true (ByPropertyName)| ---- #### **SourceIdentifier** The event source identifier. -> **Type**: ```[String[]]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|false |named |true (ByPropertyName)| ---- #### **First** If provided, will return the first N events -> **Type**: ```[Int32]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|---------|--------|--------|-------------| +|`[Int32]`|false |named |false | ---- #### **Skip** If provided, will skip the first N events. -> **Type**: ```[Int32]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|---------|--------|--------|-------------| +|`[Int32]`|false |named |false | ---- #### **InputObject** The input object. @@ -125,17 +134,15 @@ If the Input Object was a job, it will receive the results of the job. -> **Type**: ```[PSObject]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByValue) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|--------------| +|`[PSObject]`|false |named |true (ByValue)| ---- #### **Clear** If set, will remove events from the system after they have been returned, @@ -143,17 +150,20 @@ and will not keep results from Jobs or Event Handlers. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:false +|Type |Required|Position|PipelineInput| +|----------|--------|--------|-------------| +|`[Switch]`|false |named |false | + + --- + + ### Outputs * [Management.Automation.PSObject](https://learn.microsoft.com/en-us/dotnet/api/System.Management.Automation.PSObject) @@ -163,7 +173,11 @@ and will not keep results from Jobs or Event Handlers. + + --- + + ### Syntax ```PowerShell Receive-Event [-First ] [-Skip ] [-InputObject ] [-Clear] [] @@ -177,6 +191,3 @@ Receive-Event -EventIdentifier [-SourceIdentifier ] [-First ```PowerShell Receive-Event -SourceIdentifier [-First ] [-Skip ] [-InputObject ] [-Clear] [] ``` ---- - - diff --git a/docs/Repeat-EventSource.md b/docs/Repeat-EventSource.md index 242e706..25552fb 100644 --- a/docs/Repeat-EventSource.md +++ b/docs/Repeat-EventSource.md @@ -1,22 +1,37 @@ +EventSources/@Repeat.ps1 +------------------------ + + + -@Repeat.ps1 ------------ ### Synopsis Send events on repeat. + + --- + + ### Description Sends events on repeat, at a given [Timespan] -Interval. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell On Interval "00:01:00" { "Every minute" | Out-Host } ``` + + --- + + ### Parameters #### **Interval** @@ -24,22 +39,21 @@ The amount of time to wait between sending events. -> **Type**: ```[TimeSpan]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases| +|------------|--------|--------|---------------------|-------| +|`[TimeSpan]`|true |1 |true (ByPropertyName)|Every | + + --- + + ### Syntax ```PowerShell -@Repeat.ps1 [-Interval] [] +EventSources/@Repeat.ps1 [-Interval] [] ``` ---- - - - diff --git a/docs/Send-Event-EventSource.md b/docs/Send-Event-EventSource.md deleted file mode 100644 index 0ac1f76..0000000 --- a/docs/Send-Event-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Send-Event.ps1 - - - diff --git a/docs/Send-Event.md b/docs/Send-Event.md index 5d115ed..14051ac 100644 --- a/docs/Send-Event.md +++ b/docs/Send-Event.md @@ -1,10 +1,17 @@ - Send-Event ---------- + + + + ### Synopsis Sends Events + + --- + + ### Description Sends Events to PowerShell. @@ -14,7 +21,11 @@ Send-Event is a wrapper for the built-in command New-Event with a few key differ 2. You can send multiple sourceidentifiers 3. It does not output by default (you must pass -PassThru) + + --- + + ### Related Links * [New-Event](https://docs.microsoft.com/powershell/module/Microsoft.PowerShell.Utility/New-Event) @@ -24,14 +35,22 @@ Send-Event is a wrapper for the built-in command New-Event with a few key differ + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell 1..4 | Send-Event "Hit It" ``` + + --- + + ### Parameters #### **SourceIdentifier** @@ -39,85 +58,80 @@ The SourceIdentifier -> **Type**: ```[String[]]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:false +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[String[]]`|true |1 |true (ByPropertyName)| ---- #### **MessageData** The message data -> **Type**: ```[PSObject]``` -> **Required**: false -> **Position**: 2 -> **PipelineInput**:true (ByValue) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|------------------------------| +|`[PSObject]`|false |2 |true (ByValue, ByPropertyName)| ---- #### **Sender** The sender. -> **Type**: ```[PSObject]``` -> **Required**: false -> **Position**: 3 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[PSObject]`|false |3 |true (ByPropertyName)| ---- -#### **EventArgs** +#### **EventArguments** The event arguments. -> **Type**: ```[PSObject]``` -> **Required**: false -> **Position**: 4 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput |Aliases | +|------------|--------|--------|---------------------|-----------------------------| +|`[PSObject]`|false |4 |true (ByPropertyName)|SourceEventArgs
EventArgs| ---- #### **PassThru** If set, will output the created event. -> **Type**: ```[Switch]``` -> **Required**: false -> **Position**: named -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[Switch]`|false |named |true (ByPropertyName)| + + --- + + ### Outputs * [Nullable](https://learn.microsoft.com/en-us/dotnet/api/System.Nullable) @@ -127,11 +141,12 @@ If set, will output the created event. + + --- + + ### Syntax ```PowerShell -Send-Event [-SourceIdentifier] [[-MessageData] ] [[-Sender] ] [[-EventArgs] ] [-PassThru] [] +Send-Event [-SourceIdentifier] [[-MessageData] ] [[-Sender] ] [[-EventArguments] ] [-PassThru] [] ``` ---- - - diff --git a/docs/Time-EventSource.md b/docs/Time-EventSource.md index 6e59b7a..be6378c 100644 --- a/docs/Time-EventSource.md +++ b/docs/Time-EventSource.md @@ -1,41 +1,59 @@ +EventSources/@Time.ps1 +---------------------- + + + -@Time.ps1 ---------- ### Synopsis Sends an event at a specific time. + + --- + + ### Description Sends an event at a specific date and time. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell On Time "5:00 PM" { "EOD!" | Out-Host } ``` + + --- + + ### Parameters #### **DateTime** -> **Type**: ```[DateTime]``` +The specific date and time the event will be triggered. + + + + + -> **Required**: true +|Type |Required|Position|PipelineInput| +|------------|--------|--------|-------------| +|`[DateTime]`|true |1 |false | -> **Position**: 1 -> **PipelineInput**:false --- + + ### Syntax ```PowerShell -@Time.ps1 [-DateTime] [] +EventSources/@Time.ps1 [-DateTime] [] ``` ---- - - - diff --git a/docs/UDP-EventSource.md b/docs/UDP-EventSource.md index 94f51e7..a26cbf6 100644 --- a/docs/UDP-EventSource.md +++ b/docs/UDP-EventSource.md @@ -1,16 +1,27 @@ - EventSources/@UDP.ps1 --------------------- + + + + ### Synopsis Signals on UDP + + --- + + ### Description Runs PowerShell in the background. Events are fired on the completion or failure of the PowerShell command. + + --- + + ### Parameters #### **IPAddress** @@ -18,57 +29,51 @@ The IP Address where UDP packets can originate. By default, [IPAddress]::Any. -> **Type**: ```[IPAddress]``` -> **Required**: false -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|-------------|--------|--------|---------------------| +|`[IPAddress]`|false |1 |true (ByPropertyName)| ---- #### **Port** The Port used to listen for packets. -> **Type**: ```[Int32]``` -> **Required**: true -> **Position**: 2 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|---------|--------|--------|---------------------| +|`[Int32]`|true |2 |true (ByPropertyName)| ---- #### **Encoding** The encoding. If provided, packet content will be decoded. -> **Type**: ```[Encoding]``` -> **Required**: false -> **Position**: 3 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|------------|--------|--------|---------------------| +|`[Encoding]`|false |3 |true (ByPropertyName)| + + --- + + ### Syntax ```PowerShell EventSources/@UDP.ps1 [[-IPAddress] ] [-Port] [[-Encoding] ] [] ``` ---- - - - - diff --git a/docs/Understanding_Event_Sources.md b/docs/Understanding_Event_Sources.md index ae75ec0..a8f6e95 100644 --- a/docs/Understanding_Event_Sources.md +++ b/docs/Understanding_Event_Sources.md @@ -1,5 +1,6 @@ Understanding Event Sources --------------------------- + Event Sources are scripts that produce events. They are generally named @NameOfSource.ps1. @@ -19,7 +20,8 @@ Event sources can be found a few places: * In any function whose name starts with @ * In the directory where Watch-Event is defined * In the module root where Watch-Event is defined -* In an .OnQ [Hashtable] within a module manifest's private data +* In an .Eventful [Hashtable] within a module manifest's private data +* In a module that .Tags Eventful You can see the event sources currently available with: diff --git a/docs/VariableSet-EventSource.md b/docs/VariableSet-EventSource.md index ffb692f..8342fa7 100644 --- a/docs/VariableSet-EventSource.md +++ b/docs/VariableSet-EventSource.md @@ -1,10 +1,17 @@ - EventSources/@VariableSet.ps1 ----------------------------- + + + + ### Synopsis Watches for variable sets. + + --- + + ### Description Watches for assignments to a variable. @@ -13,7 +20,11 @@ Events are sent directly after the variable is set. The -Sender is the callstack, The -MessageData is the value of the variable. + + --- + + ### Parameters #### **VariableName** @@ -21,23 +32,21 @@ The name of the variable -> **Type**: ```[String]``` -> **Required**: true -> **Position**: 1 -> **PipelineInput**:true (ByPropertyName) +|Type |Required|Position|PipelineInput | +|----------|--------|--------|---------------------| +|`[String]`|true |1 |true (ByPropertyName)| + + --- + + ### Syntax ```PowerShell EventSources/@VariableSet.ps1 [-VariableName] [] ``` ---- - - - - diff --git a/docs/Watch-Event-EventSource.md b/docs/Watch-Event-EventSource.md deleted file mode 100644 index 3302be0..0000000 --- a/docs/Watch-Event-EventSource.md +++ /dev/null @@ -1,4 +0,0 @@ -Watch-Event.ps1 - - - diff --git a/docs/Watch-Event.md b/docs/Watch-Event.md index b767bc5..59197b7 100644 --- a/docs/Watch-Event.md +++ b/docs/Watch-Event.md @@ -1,15 +1,26 @@ - Watch-Event ----------- + + + + ### Synopsis Watches Events + + --- + + ### Description Watches Events by SourceIdentifier, or using an EventSource script. + + --- + + ### Related Links * [Get-EventSource](Get-EventSource.md) @@ -31,7 +42,11 @@ Watches Events by SourceIdentifier, or using an EventSource script. + + --- + + ### Examples #### EXAMPLE 1 ```PowerShell @@ -43,7 +58,11 @@ Watch-Event -SourceIdentifier MySignal -Then {"fire!" | Out-Host } On MySignal { "fire!" | Out-host } ``` New-Event MySignal + + --- + + ### Outputs * [Nullable](https://learn.microsoft.com/en-us/dotnet/api/System.Nullable) @@ -53,11 +72,12 @@ New-Event MySignal + + --- + + ### Syntax ```PowerShell Watch-Event [] ``` ---- - - diff --git a/docs/_config.yml b/docs/_config.yml index eee21c8..83650a3 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,2 +1 @@ -theme: jekyll-theme-midnight permalink: pretty \ No newline at end of file diff --git a/docs/get_Description-EventSource.md b/docs/get_Description-EventSource.md deleted file mode 100644 index 02b0a0f..0000000 --- a/docs/get_Description-EventSource.md +++ /dev/null @@ -1,9 +0,0 @@ -get_Description.ps1 - - - - - - - - diff --git a/docs/get_EventSourceID-EventSource.md b/docs/get_EventSourceID-EventSource.md deleted file mode 100644 index 5fd7695..0000000 --- a/docs/get_EventSourceID-EventSource.md +++ /dev/null @@ -1,6 +0,0 @@ -get_EventSourceID.ps1 - - - - - diff --git a/docs/get_Help-EventSource.md b/docs/get_Help-EventSource.md deleted file mode 100644 index 81372eb..0000000 --- a/docs/get_Help-EventSource.md +++ /dev/null @@ -1,9 +0,0 @@ -get_Help.ps1 - - - - - - - - diff --git a/docs/get_IsSpecificEvent-EventSource.md b/docs/get_IsSpecificEvent-EventSource.md deleted file mode 100644 index c1e3d8b..0000000 --- a/docs/get_IsSpecificEvent-EventSource.md +++ /dev/null @@ -1,6 +0,0 @@ -get_IsSpecificEvent.ps1 - - - - - diff --git a/docs/get_Name-EventSource.md b/docs/get_Name-EventSource.md deleted file mode 100644 index 6a62992..0000000 --- a/docs/get_Name-EventSource.md +++ /dev/null @@ -1,6 +0,0 @@ -get_Name.ps1 - - - - - diff --git a/docs/get_SourceIdentifier-EventSource.md b/docs/get_SourceIdentifier-EventSource.md deleted file mode 100644 index bc74619..0000000 --- a/docs/get_SourceIdentifier-EventSource.md +++ /dev/null @@ -1,6 +0,0 @@ -get_SourceIdentifier.ps1 - - - - - diff --git a/docs/get_Synopsis-EventSource.md b/docs/get_Synopsis-EventSource.md deleted file mode 100644 index 7876919..0000000 --- a/docs/get_Synopsis-EventSource.md +++ /dev/null @@ -1,9 +0,0 @@ -get_Synopsis.ps1 - - - - - - - - diff --git a/en-us/Understanding_Event_Sources.help.txt b/en-us/Understanding_Event_Sources.help.txt index 6181384..c350e08 100644 --- a/en-us/Understanding_Event_Sources.help.txt +++ b/en-us/Understanding_Event_Sources.help.txt @@ -1,5 +1,6 @@ Understanding Event Sources --------------------------- + Event Sources are scripts that produce events. They are generally named @NameOfSource.ps1. @@ -19,7 +20,8 @@ Event sources can be found a few places: * In any function whose name starts with @ * In the directory where Watch-Event is defined * In the module root where Watch-Event is defined -* In an .OnQ [Hashtable] within a module manifest's private data +* In an .Eventful [Hashtable] within a module manifest's private data +* In a module that .Tags Eventful You can see the event sources currently available with: