Skip to content

Pipe script updates #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 138 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
07d2b73
Updating Inline Transpilers: Requiring [Management.Automation.Comman…
Aug 13, 2022
81c4681
Updating Inline Transpilers: Requiring [Management.Automation.Comman…
Aug 13, 2022
3b9c9f4
Updating Inline Transpilers: Requiring [Management.Automation.Comman…
Aug 13, 2022
f62cffe
[CommandAst].ResolvedCommand: Checking transpilers first (Fixes #186)
Aug 13, 2022
20238d6
[CommandAst].ResolvedCommand: Checking transpilers first (Fixes #186)
Aug 13, 2022
c00fd7b
[ScriptBlock]/[AST]: Adding .Transpilers (Fixes #185)
Aug 13, 2022
494111b
[ScriptBlock]/[AST]: Adding .Transpilers (Fixes #185)
Aug 13, 2022
8940f8f
Adding Hashtable formatter (Fixes #187)
Aug 13, 2022
573b65d
Adding Hashtable formatter (Fixes #187)
Aug 13, 2022
f6b9c71
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
5846fed
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
12c6236
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
e69e8a9
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
26cf931
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
8da73c4
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
60b65f4
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
4f161e1
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
26c40c5
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
153a9ea
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
723487c
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
7ebad9f
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
5f223fa
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
5aa0461
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
f709186
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
d88af2d
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
0db4f46
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
7deebd5
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
b8ba2e9
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
695bf29
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
0196541
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
28b3d53
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
287d08b
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
0fb0743
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
da0770c
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
f48a456
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
7afb1f6
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
cf2ca82
HTTP Protocol: Enabling Splatting (Fixes #183)
Aug 14, 2022
56bc634
Core Transpiler: Allowing -ScriptBlock to be provided postionally (F…
Aug 14, 2022
4dfb40b
Use-PipeScript: Defaulting to core transpiler (Fixes #188)
Aug 14, 2022
3360691
Use-PipeScript: Defaulting to core transpiler (Fixes #188)
Aug 14, 2022
455d864
Adding [AST].Transpile() (Fixes #192)
Aug 28, 2022
da0a948
Adding [AST].Transpile() (Fixes #192)
Aug 28, 2022
50a039c
new keyword property bag improvements (Fixes #191)
Aug 28, 2022
b577258
Considering a pipeline in a hashtable to be assigned (Fixes #193)
Aug 28, 2022
1a417b5
Considering a pipeline in a hashtable to be assigned (Fixes #193)
Aug 28, 2022
cd8bf72
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
77d92da
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
7da7d6f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
ddc06bd
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
6458fef
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
c6ddf6c
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
c7aa98e
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
93dc65b
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
161fec2
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8303c63
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
56e89f2
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
5516cfb
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
1afbd64
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
49657f1
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
0aa4dc3
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
f9cebbf
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
471cd1e
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8417216
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
6199d47
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8daef87
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
f11e2e4
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
ca3e43f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
72df223
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
50e88ac
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
cbc4f6e
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
690efe0
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
f2c272a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
72f3a25
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
c1eb266
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
62be63a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
423cfab
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
326b8b6
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8b63f03
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
0b44e74
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
6de6ef0
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
85bfab8
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
47dd4dd
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
66836ed
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
1bf8b0d
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
6e2bf60
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
cd2b46a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
da2f252
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
e9ec440
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
2536c7f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8702a09
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
b5af627
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
bc3a3e4
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
03575cc
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
a57057d
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
da4a3c8
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
e5f9a31
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
667ae0f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
5f7e13a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
1e830b2
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
f558406
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
610afe6
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
244082f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
ecd69f4
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
8d48e69
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
2ae8340
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
ecdde8a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
a46e097
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
5f2c599
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
24b42b3
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
cacdadc
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
f488c2b
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
24bed2e
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
33785a7
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
5d7b07a
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
07784e3
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
4c1816f
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
3a53416
Updating Inline Transpilers Readme: Adding heading and removing some…
Aug 30, 2022
ce64463
Updating Inline Transpilers Readme: Adding Contributing Section
Aug 30, 2022
0346432
Updating Inline Transpilers Readme: Adding Contributing Section
Aug 30, 2022
21cb317
Updating Inline Transpilers Readme: Removing Redundancies
Aug 30, 2022
25c1e98
Updating Inline Transpilers Readme: Removing Redundancies
Aug 30, 2022
72fb93d
Adding Support for PipeScript in Bash (Fixes #194)
Aug 30, 2022
579406f
Adding Support for PipeScript in Bash (Fixes #194)
Aug 30, 2022
818daa6
New-PipeScript: Writing help (Fixes #195) and functions (fixes #196)
Sep 6, 2022
1a66490
New-PipeScript: Writing help (Fixes #195) and functions (fixes #196)
Sep 6, 2022
5b3ce75
New-PipeScript: Writing help (Fixes #195) and functions (fixes #196)
Sep 6, 2022
6cd68c9
New-PipeScript: Adding inline documentation.
Sep 6, 2022
36fd191
New-PipeScript: Adding inline documentation.
Sep 6, 2022
679a45c
New-PipeScript: Adding inline documentation.
Sep 6, 2022
432e8ce
Core Inline Transpiler : Adding -LinePattern (fixes #197)
Sep 8, 2022
d3ffbb7
Core Inline Transpiler : Adding -LinePattern (fixes #197)
Sep 8, 2022
0a34586
Core Inline Transpiler : Adding -LinePattern (fixes #197)
Sep 8, 2022
0f08318
Adding Inline Batch support (Fixes #198)
Sep 8, 2022
929fa02
Adding Inline Batch support (Fixes #198)
Sep 8, 2022
87c579d
Inline Batch support: improving inner docs (re #198)
Sep 8, 2022
aed83bf
Inline Batch support: improving inner docs (re #198)
Sep 8, 2022
ffc33e7
Updating Module Version [0.1.2] and CHANGELOG
Sep 8, 2022
a030834
Updating Module Version [0.1.2] and CHANGELOG
Sep 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 0.1.2:
* New Inline Language support
* Batch support (Fixes #198)
* Bash Support (Fixes #194)
* Core Inline Transpiler : Adding -LinePattern (fixes #197)
* New-PipeScript: Writing help (Fixes #195) and functions (fixes #196)
* AST Type Improvements:
* Adding [AST].Transpile() (Fixes #192)
* Considering a pipeline in a hashtable to be assigned (Fixes #193)
* [ScriptBlock]/[AST]: Adding .Transpilers (Fixes #185)
* [CommandAst].ResolvedCommand: Checking transpilers first (Fixes #186)
* Improvements:
* new keyword property bag improvements (Fixes #191)
* Use-PipeScript: Defaulting to core transpiler (Fixes #188)
* Core Transpiler: Allowing -ScriptBlock to be provided postionally (Fixes #189)
* Adding Hashtable formatter (Fixes #187)
* HTTP Protocol: Enabling Splatting (Fixes #183)
* Requiring Inline Transpilers accept [Management.Automation.CommandInfo] from the Pipeline (Fixes #184)
---

## 0.1.1:
* New Keywords:
* await (Fixes #181)
Expand Down
3 changes: 3 additions & 0 deletions Formatting/Hashtable.format.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Write-FormatView -TypeName Hashtable -Name Hashtable -Action {
$_ | Format-Hashtable -Depth $FormatEnumerationLimit
}
28 changes: 18 additions & 10 deletions Get-PipeScript.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
#region Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell
# Install-Module Piecemeal -Scope CurrentUser
# Import-Module Piecemeal -Force
# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
Expand Down Expand Up @@ -230,7 +230,7 @@ function Get-PipeScript
}

$extCmd.PSObject.Methods.Add([psscriptmethod]::new('GetExtendedCommands', {

param([Management.Automation.CommandInfo[]]$CommandList)
$extendedCommandNames = @(
foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -isnot [Management.Automation.CmdletAttribute]) { continue }
Expand All @@ -244,13 +244,16 @@ function Get-PipeScript
$this | Add-Member NoteProperty ExtensionCommands @() -Force
return
}
$allLoadedCmds = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','All', $true)
if (-not $CommandList) {
$commandList = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function,Alias,Cmdlet', $true)
}
$extends = @{}
foreach ($loadedCmd in $allLoadedCmds) {
:nextCommand foreach ($loadedCmd in $commandList) {
foreach ($extensionCommandName in $extendedCommandNames) {
if ($extensionCommandName -and $loadedCmd.Name -match $extensionCommandName) {
$loadedCmd
$extends[$loadedCmd.Name] = $loadedCmd
continue nextCommand
}
}
}
Expand All @@ -263,7 +266,12 @@ function Get-PipeScript
$this | Add-Member NoteProperty ExtensionCommands $extends.Values -Force
}))

$null = $extCmd.GetExtendedCommands()
if (-not $script:AllCommands) {
$script:AllCommands = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function,Alias,Cmdlet', $true)
}


$null = $extCmd.GetExtendedCommands($script:AllCommands)

$inheritanceLevel = [ComponentModel.InheritanceLevel]::Inherited

Expand Down Expand Up @@ -824,9 +832,8 @@ function Get-PipeScript
return $allDynamicParameters
}
}
}
#endregion Define Inner Functions

}
#endregion Define Inner Functions

$extensionFullRegex =
[Regex]::New($(
Expand All @@ -847,7 +854,8 @@ function Get-PipeScript
$getCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand

if ($Force) {
$script:PipeScripts = $null
$script:PipeScripts = $null
$script:AllCommands = @()
}
if (-not $script:PipeScripts)
{
Expand Down Expand Up @@ -917,5 +925,5 @@ function Get-PipeScript
}
}
}
#endregion Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
#endregion Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell

28 changes: 18 additions & 10 deletions Get-Transpiler.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
#region Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell
# Install-Module Piecemeal -Scope CurrentUser
# Import-Module Piecemeal -Force
# Install-Piecemeal -ExtensionNoun 'Transpiler' -ExtensionPattern '\.psx\.ps1$' -ExtensionTypeName 'PipeScript.Transpiler' -OutputPath '.\Get-Transpiler.ps1'
Expand Down Expand Up @@ -230,7 +230,7 @@ function Get-Transpiler
}

$extCmd.PSObject.Methods.Add([psscriptmethod]::new('GetExtendedCommands', {

param([Management.Automation.CommandInfo[]]$CommandList)
$extendedCommandNames = @(
foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -isnot [Management.Automation.CmdletAttribute]) { continue }
Expand All @@ -244,13 +244,16 @@ function Get-Transpiler
$this | Add-Member NoteProperty ExtensionCommands @() -Force
return
}
$allLoadedCmds = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','All', $true)
if (-not $CommandList) {
$commandList = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function,Alias,Cmdlet', $true)
}
$extends = @{}
foreach ($loadedCmd in $allLoadedCmds) {
:nextCommand foreach ($loadedCmd in $commandList) {
foreach ($extensionCommandName in $extendedCommandNames) {
if ($extensionCommandName -and $loadedCmd.Name -match $extensionCommandName) {
$loadedCmd
$extends[$loadedCmd.Name] = $loadedCmd
continue nextCommand
}
}
}
Expand All @@ -263,7 +266,12 @@ function Get-Transpiler
$this | Add-Member NoteProperty ExtensionCommands $extends.Values -Force
}))

$null = $extCmd.GetExtendedCommands()
if (-not $script:AllCommands) {
$script:AllCommands = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function,Alias,Cmdlet', $true)
}


$null = $extCmd.GetExtendedCommands($script:AllCommands)

$inheritanceLevel = [ComponentModel.InheritanceLevel]::Inherited

Expand Down Expand Up @@ -824,9 +832,8 @@ function Get-Transpiler
return $allDynamicParameters
}
}
}
#endregion Define Inner Functions

}
#endregion Define Inner Functions

$extensionFullRegex =
[Regex]::New($(
Expand All @@ -847,7 +854,8 @@ function Get-Transpiler
$getCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand

if ($Force) {
$script:Transpilers = $null
$script:Transpilers = $null
$script:AllCommands = @()
}
if (-not $script:Transpilers)
{
Expand Down Expand Up @@ -917,5 +925,5 @@ function Get-Transpiler
}
}
}
#endregion Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
#endregion Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell

74 changes: 70 additions & 4 deletions New-PipeScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,28 @@ HTTP Accept indicates what content types the web request will accept as a respon
#>
[Alias('WeakType', 'WeakParameters', 'WeaklyTypedParameters', 'WeakProperties', 'WeaklyTypedProperties')]
[switch]
$WeaklyTyped
$WeaklyTyped,
# The name of the function to create.
[string]
$FunctionName,
# The type of the function to create. This will be ignored if -FunctionName is not passed.
[string]
$FunctionType = 'function',
# A description of the script's functionality. If provided with -Synopsis, will generate help.
[string]
$Description,
# A short synopsis of the script's functionality. If provided with -Description, will generate help.
[string]
$Synopsis,
# A list of examples to use in help. Will be ignored if -Synopsis and -Description are not passed.
[string[]]
$Example,
# A list of links to use in help. Will be ignored if -Synopsis and -Description are not passed.
[string[]]
$Link,
# A list of attributes to declare on the scriptblock.
[string[]]
$Attribute
)
begin {
$ParametersToCreate = [Ordered]@{}
Expand All @@ -177,6 +198,36 @@ HTTP Accept indicates what content types the web request will accept as a respon
}
}
process {
if ($Synopsis -and $Description) {
function indentHelpLine {
foreach ($line in $args -split '(?>\r\n|\n)') {
(' ' * 4) + $line.Trim()
}

}
$helpHeader = @(
"<#"
".Synopsis"
indentHelpLine $Synopsis
".Description"
indentHelpLine $Description

foreach ($helpExample in $Example) {
".Example"
indentHelpLine $helpExample
}
foreach ($helplink in $Link) {
".Link"
indentHelpLine $link
}
"#>"
) -join [Environment]::Newline
$allHeaders += $helpHeader
}

if ($Attribute) {
$allHeaders += $Attribute
}
if ($parameter) {
# The -Parameter can be a dictionary of parameters.
if ($Parameter -is [Collections.IDictionary]) {
Expand Down Expand Up @@ -252,6 +303,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
$parameter
}
}
# If the -Parameter was provided via reflection
elseif ($parameter -is [Reflection.PropertyInfo] -or
$parameter -as [Reflection.PropertyInfo[]] -or
$parameter -is [Reflection.ParameterInfo] -or
Expand Down Expand Up @@ -324,15 +376,21 @@ HTTP Accept indicates what content types the web request will accept as a respon
# accumulate them.
$allEndBlocks += $end
}
# If -AutoParameter was passed
if ($AutoParameter) {
# Find all of the variable expressions within -Begin, -Process, and -End
$variableDefinitions = $Begin, $Process, $End |
Where-Object { $_ } |
Search-PipeScript -AstType VariableExpressionAST |
Select-Object -ExpandProperty Result
foreach ($var in $variableDefinitions) {
# Then, see where those variables were assigned
$assigned = $var.GetAssignments()
# (if they were assigned, keep moving)
if ($assigned) { continue }
# If there were not assigned
$varName = $var.VariablePath.userPath.ToString()
# add it to the list of parameters to create.
$ParametersToCreate[$varName] = @(
@(
"[Parameter(ValueFromPipelineByPropertyName)]"
Expand All @@ -359,7 +417,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
$newParamBlock = $parameterScriptBlocks | Join-PipeScript
}
# Create the script block by combining together the provided parts.
$createdScriptBlock = [scriptblock]::Create("
$createdScriptBlock = [scriptblock]::Create("$(if ($functionName) { "$functionType $FunctionName {"})
$($allHeaders -join [Environment]::Newline)
$newParamBlock
$(if ($allDynamicParameters) {
Expand All @@ -376,9 +434,17 @@ $(if ($allEndBlocks -and -not $allBeginBlocks -and -not $allProcessBlocks) {
} elseif ($allEndBlocks) {
@(@("end {") + $allEndBlocks + '}') -join [Environment]::Newline
})
$(if ($FunctionName) { '}'})
")
# return the created script block.
return $createdScriptBlock
# If we have a -FunctionName and the -FunctionType is not a built-in function type
if ($CreatedScriptBlock -and
$functionName -and $FunctionType -notin 'function', 'filter') {
# return the transpiled script.
return $createdScriptBlock.Transpile()
} else {
# otherwise, return the created script.
return $createdScriptBlock
}
}
}

Loading