-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using branch build of ShowDemo Action (re #37)
- Loading branch information
StartAutomating
authored and
StartAutomating
committed
May 22, 2023
1 parent
1640468
commit 97c2fed
Showing
1 changed file
with
72 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,87 @@ | ||
Get-Demo | ||
-------- | ||
### | ||
|
||
|
||
|
||
|
||
### Synopsis | ||
Gets Demos | ||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Description | ||
|
||
Gets PowerShell Demos. | ||
Demos located in ShowDemo and all modules that tag ShowDemo will be automatically discovered. | ||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Related Links | ||
* [Import-Demo](Import-Demo.md) | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Examples | ||
#### EXAMPLE 1 | ||
```PowerShell | ||
Get-Demo | ||
function Get-Demo | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Gets Demos | ||
.DESCRIPTION | ||
Gets PowerShell Demos. | ||
Demos located in ShowDemo and all modules that tag ShowDemo will be automatically discovered. | ||
.LINK | ||
Import-Demo | ||
.EXAMPLE | ||
Get-Demo | ||
#> | ||
[CmdletBinding(DefaultParameterSetName='LoadedDemos')] | ||
param( | ||
# The name of the demo | ||
[Parameter(ValueFromPipelineByPropertyName,ParameterSetName='LoadedDemos')] | ||
[string] | ||
$DemoName, | ||
``` | ||
|
||
```PowerShell | ||
# The path to the demo file. | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='DemoFile')] | ||
[Alias('FullName', 'DemoFile', 'File', 'Source')] | ||
$DemoPath, | ||
``` | ||
|
||
```PowerShell | ||
# A Demo Script block. | ||
[Parameter(Mandatory,ValueFromPipeline,ParameterSetName='DemoScript')] | ||
[scriptblock] | ||
$DemoScript | ||
) | ||
``` | ||
|
||
--- | ||
|
||
|
||
### Parameters | ||
#### **DemoName** | ||
|
||
The name of the demo | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput | | ||
|----------|--------|--------|---------------------| | ||
|`[String]`|false |named |true (ByPropertyName)| | ||
|
||
|
||
|
||
#### **DemoPath** | ||
|
||
The path to the demo file. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput |Aliases | | ||
|----------|--------|--------|---------------------|-----------------------------------------| | ||
|`[Object]`|true |named |true (ByPropertyName)|FullName<br/>DemoFile<br/>File<br/>Source| | ||
|
||
|
||
|
||
#### **DemoScript** | ||
|
||
A Demo Script block. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|Type |Required|Position|PipelineInput | | ||
|---------------|--------|--------|--------------| | ||
|`[ScriptBlock]`|true |named |true (ByValue)| | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
```PowerShell | ||
begin { | ||
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module | ||
} | ||
``` | ||
|
||
```PowerShell | ||
process { | ||
if ($PSCmdlet.ParameterSetName -in 'DemoFile', 'DemoScript') { | ||
Import-Demo @psboundParameters | ||
return | ||
} | ||
``` | ||
|
||
### Syntax | ||
```PowerShell | ||
Get-Demo [-DemoName <String>] [<CommonParameters>] | ||
$filePaths = | ||
@( | ||
$pwd | ||
if ($myModule) { | ||
$moduleRelationships = [ModuleRelationships()]$myModule | ||
foreach ($relationship in $moduleRelationships) { | ||
$relationship.RelatedModule | Split-Path | ||
} | ||
} else { | ||
$PSScriptRoot | ||
} | ||
) | ||
``` | ||
|
||
|
||
|
||
```PowerShell | ||
Get-Demo -DemoPath <Object> [<CommonParameters>] | ||
$allDemoFiles = | ||
all scripts in $filePaths that { | ||
$_.Name -match '^(?>demo|walkthru)\.ps1$' -or | ||
$_.Name -match '\.(?>demo|walkthru)\.ps1$' | ||
} are demofiles | ||
``` | ||
|
||
```PowerShell | ||
Get-Demo -DemoScript <ScriptBlock> [<CommonParameters>] | ||
$allDemoFiles | | ||
Where-Object Name -like "*$demoName*" | | ||
Import-Demo | ||
} | ||
} | ||
``` |