Skip to content

Commit 258b434

Browse files
Merge pull request #208 from StartAutomating/EZ-Updates
EZOut 2.0.4
2 parents e981f8e + f2e7459 commit 258b434

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+250
-2712
lines changed

.github/workflows/TestReleaseAndPublish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,11 @@ jobs:
585585
- name: Initialize Splatter
586586
uses: StartAutomating/Splatter@main
587587
id: Splatter
588-
- name: BuildPipeScript
588+
- name: PipeScript
589589
uses: StartAutomating/PipeScript@main
590+
id: PipeScript
591+
with:
592+
serial: true
590593
- name: Run EZOut (on master)
591594
if: ${{github.ref_name == 'master'}}
592595
uses: StartAutomating/EZOut@master

Build/GitHub/Jobs/BuildEZOut.psd1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
uses = 'StartAutomating/Splatter@main'
2222
id = 'Splatter'
2323
},
24-
'RunPipeScript',
24+
@{
25+
name = 'PipeScript'
26+
uses = 'StartAutomating/PipeScript@main'
27+
id = 'PipeScript'
28+
with = @{
29+
serial = $true
30+
}
31+
},
2532
@{
2633
name = 'Run EZOut (on master)'
2734
if = '${{github.ref_name == ''master''}}'

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## EZOut 2.0.4:
2+
3+
* Write-FormatViewExpression/Write-FormatCustomView now support -Frame, -LeftIndent, -RightIndent, -FirstLineHanging, -FirstLineIndent ( Fixes #164 )
4+
* Push-FormatData/Push-TypeData now create unique files per-process (Fixes #205 )
5+
6+
Thanks @NinMonkey !
7+
18
## EZOut 2.0.3:
29

310
* Mounting EZOut as a drive (#200)

Commands/Format.PS1XML/Out-FormatData.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function Out-FormatData {
2+
23
<#
34
.Synopsis
45
Takes a series of format views and format actions and outputs a format data XML
@@ -44,13 +45,15 @@ function Out-FormatData {
4445
# If it is a dictionary, the keys must a be a `[string]` or `[regex]` defining a pattern, and the value will be the path.
4546
[ValidateScript({
4647
$validTypeList = [System.String],[System.Collections.IDictionary]
48+
4749
$thisType = $_.GetType()
4850
$IsTypeOk =
4951
$(@( foreach ($validType in $validTypeList) {
5052
if ($_ -as $validType) {
5153
$true;break
5254
}
5355
}))
56+
5457
if (-not $isTypeOk) {
5558
throw "Unexpected type '$(@($thisType)[0])'. Must be 'string','System.Collections.IDictionary'."
5659
}
@@ -74,6 +77,7 @@ $Aspect = {
7477
$selectionSets = ""
7578

7679
function findUsedParts {
80+
7781
param(
7882
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
7983
[Alias('InnerText','ScriptBlock','ScriptContents')]
@@ -197,6 +201,7 @@ $Aspect = {
197201

198202
}
199203
filter ReplaceParts {
204+
200205
if ($DebugPreference -ne 'silentlyContinue') {
201206
$in = $_
202207
if ($in.InnerText) { return $in.InnerText}
@@ -414,6 +419,7 @@ $Aspect = {
414419
if ($OutputPath) {
415420
$alreadyExportedTypeNames = @{}
416421
$allTypeNames = @()
422+
417423
if ($outputPath -is [string]) {
418424
$createdOutputFile = New-Item -ItemType File -Path $OutputPath -Force
419425
if (-not $createdOutputFile) { return }
@@ -482,6 +488,7 @@ $Aspect = {
482488
}
483489

484490
}
491+
485492
}
486493

487494

-4.54 KB
Binary file not shown.

Commands/Format.PS1XML/Write-FormatCustomView.ps1

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,35 @@
2323
[Alias('ScriptBlock')]
2424
[ScriptBlock[]]$Action,
2525

26-
# The indentation depth of the custom control
27-
[Parameter(ValueFromPipelineByPropertyName=$true)]
28-
[int]$Indent,
26+
# If set, will put the expression within a <Frame> element.
27+
[Parameter(ValueFromPipelineByPropertyName)]
28+
[switch]
29+
$Frame,
30+
31+
# If provided, will indent by a number of characters. This implies -Frame.
32+
[Parameter(ValueFromPipelineByPropertyName)]
33+
[Alias('Indent')]
34+
[ValidateRange(0,1mb)]
35+
[int]
36+
$LeftIndent,
37+
38+
# If provided, will indent the right by a number of characters. This implies -Frame.
39+
[Parameter(ValueFromPipelineByPropertyName)]
40+
[ValidateRange(0,1mb)]
41+
[int]
42+
$RightIndent,
43+
44+
# Specifies how many characters the first line of data is shifted to the left. This implies -Frame.
45+
[Parameter(ValueFromPipelineByPropertyName)]
46+
[ValidateRange(0,1mb)]
47+
[int]
48+
$FirstLineHanging,
49+
50+
# Specifies how many characters the first line of data is shifted to the right. This implies -Frame.
51+
[Parameter(ValueFromPipelineByPropertyName)]
52+
[ValidateRange(0,1mb)]
53+
[int]
54+
$FirstLineIndent,
2955

3056
# If set, the content will be created as a control. Controls can be reused by other formatters.
3157
[Switch]$AsControl,
@@ -86,12 +112,29 @@ $header = @"
86112
<CustomEntry>
87113
$entrySelectedBy
88114
<CustomItem>
89-
$(if ($Indent) { "<Frame><LeftIndent>$Indent</LeftIndent><CustomItem>" } )
115+
$(
116+
if ($Frame -or $FirstLineHanging -or $LeftIndent -or $RightIndent -or $FirstLineIndent) {
117+
"
118+
<Frame>
119+
$(
120+
if ($LeftIndent) { "<LeftIndent>$LeftIndent</LeftIndent>" }
121+
if ($RightIndent) { "<RightIndent>$RightIndent</RightIndent>" }
122+
if ($FirstLineHanging) { "<FirstLineHanging>$FirstLineHanging</FirstLineHanging>" }
123+
if ($FirstLineIndent) { "<FirstLineIndent>$FirstLineIndent</FirstLineIndent>" }
124+
)
125+
<CustomItem>
126+
"
127+
}
128+
)
90129
91130
"@
92131

93132
$footer = @"
94-
$(if ($indent) {"</CustomItem></Frame>"})
133+
$(
134+
if ($Frame -or $FirstLineHanging -or $LeftIndent -or $RightIndent -or $FirstLineIndent) {
135+
"</CustomItem></Frame>"
136+
}
137+
)
95138
</CustomItem>
96139
</CustomEntry>
97140
"@
@@ -139,7 +182,7 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))
139182
</ExpressionBinding>"
140183
}
141184
}
142-
185+
143186
$entries += ( $header + $middle + $footer)
144187
}
145188

Commands/Format.PS1XML/Write-FormatViewExpression.ps1

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,28 @@
2020
.Example
2121
# This will render the property 'Status' of the current object,
2222
# if the current object's 'Complete' property is $false.
23-
Write-FormatViewExpression -Property Status -If { -not $_.Complete }
24-
23+
Write-FormatViewExpression -Property Status -If { -not $_.Complete }
2524
#>
2625
[CmdletBinding(DefaultParameterSetName='ScriptBlock')]
2726
[OutputType([string])]
2827
[Alias('Show-CustomAction')]
2928
param(
3029
# The name of the control. If this is provided, it will be used to display the property or script block.
31-
[Parameter(ValueFromPipelineByPropertyName=$true)]
30+
[Parameter(ValueFromPipelineByPropertyName)]
3231
[Alias('ActionName','Name')]
3332
[String]
3433
$ControlName,
3534

3635
# If a property name is provided, then the custom action will show the contents
3736
# of the property
38-
[Parameter(Mandatory=$true,ParameterSetName='Property',Position=0,ValueFromPipelineByPropertyName=$true)]
37+
[Parameter(Mandatory=$true,ParameterSetName='Property',Position=0,ValueFromPipelineByPropertyName)]
3938
[Alias('PropertyName')]
4039
[String]
4140
$Property,
4241

4342
# If a script block is provided, then the custom action shown in formatting
4443
# will be the result of the script block.
45-
[Parameter(Mandatory=$true,ParameterSetName='ScriptBlock',Position=0,ValueFromPipelineByPropertyName=$true)]
44+
[Parameter(Mandatory=$true,ParameterSetName='ScriptBlock',Position=0,ValueFromPipelineByPropertyName)]
4645
[ScriptBlock]
4746
$ScriptBlock,
4847

@@ -53,7 +52,7 @@
5352
$If,
5453

5554
# If provided, will output the provided text. All other parameters are ignored.
56-
[Parameter(Mandatory,ParameterSetName='Text',ValueFromPipelineByPropertyName=$true)]
55+
[Parameter(Mandatory,ParameterSetName='Text',ValueFromPipelineByPropertyName)]
5756
[string]
5857
$Text,
5958

@@ -73,10 +72,40 @@
7372
$ResourceID,
7473

7574
# If provided, will output a <NewLine /> element. All other parameters are ignored.
76-
[Parameter(Mandatory=$true,ParameterSetName='NewLine',ValueFromPipelineByPropertyName=$true)]
75+
[Parameter(Mandatory=$true,ParameterSetName='NewLine',ValueFromPipelineByPropertyName)]
7776
[switch]
7877
$Newline,
7978

79+
# If set, will put the expression within a <Frame> element.
80+
[Parameter(ValueFromPipelineByPropertyName)]
81+
[switch]
82+
$Frame,
83+
84+
# If provided, will indent by a number of characters. This implies -Frame.
85+
[Parameter(ValueFromPipelineByPropertyName)]
86+
[Alias('Indent')]
87+
[ValidateRange(0,1mb)]
88+
[int]
89+
$LeftIndent,
90+
91+
# If provided, will indent the right by a number of characters. This implies -Frame.
92+
[Parameter(ValueFromPipelineByPropertyName)]
93+
[ValidateRange(0,1mb)]
94+
[int]
95+
$RightIndent,
96+
97+
# Specifies how many characters the first line of data is shifted to the left. This implies -Frame.
98+
[Parameter(ValueFromPipelineByPropertyName)]
99+
[ValidateRange(0,1mb)]
100+
[int]
101+
$FirstLineHanging,
102+
103+
# Specifies how many characters the first line of data is shifted to the right. This implies -Frame.
104+
[Parameter(ValueFromPipelineByPropertyName)]
105+
[ValidateRange(0,1mb)]
106+
[int]
107+
$FirstLineIndent,
108+
80109
# The name of one or more $psStyle properties to apply.
81110
# If $psStyle is present, this will use put these properties prior to an expression.
82111
# A $psStyle.Reset will be outputted after the expression.
@@ -157,7 +186,8 @@
157186
# With script blocks, the variables $N and $Number will be set to indicate the current iteration.
158187
[ValidateRange(1,10kb)]
159188
[uint32]
160-
$Count = 1)
189+
$Count = 1
190+
)
161191

162192
process {
163193
# If this is calling itself recursively in ScriptBlock
@@ -270,6 +300,21 @@ $if")
270300
</ExpressionBinding>
271301
"@
272302

303+
if ($Frame -or $FirstLineHanging -or $LeftIndent -or $RightIndent -or $FirstLineIndent) {
304+
$formatExpression = "
305+
<Frame>
306+
$(
307+
if ($LeftIndent) { "<LeftIndent>$LeftIndent</LeftIndent>" }
308+
if ($RightIndent) { "<RightIndent>$RightIndent</RightIndent>" }
309+
if ($FirstLineHanging) { "<FirstLineHanging>$FirstLineHanging</FirstLineHanging>" }
310+
if ($FirstLineIndent) { "<FirstLineIndent>$FirstLineIndent</FirstLineIndent>" }
311+
)
312+
<CustomItem>
313+
$FormatExpression
314+
</CustomItem>
315+
</Frame>
316+
"
317+
}
273318
$xml = [xml]$formatExpression
274319
if (-not $xml) { return }
275320
$xOut=[IO.StringWriter]::new()

Commands/FormattingExtended/Format-JSON.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function Format-JSON {
3535
}
3636
$IncludeParameter = @()
3737
$ExcludeParameter = @()
38+
39+
3840
$DynamicParameters = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
3941
:nextInputParameter foreach ($paramName in ([Management.Automation.CommandMetaData]$baseCommand).Parameters.Keys) {
4042
if ($ExcludeParameter) {
@@ -57,6 +59,7 @@ function Format-JSON {
5759
))
5860
}
5961
$DynamicParameters
62+
6063
}
6164
begin {
6265
$accumulateInput = [Collections.Queue]::new()
@@ -75,12 +78,15 @@ function Format-JSON {
7578

7679
}
7780
end {
81+
7882
$joiner = "," + $(
7983
if (-not $PSBoundParameters["Compress"]) {
8084
[System.Environment]::NewLine
8185
}
8286
)
87+
8388
$null = $PSBoundParameters.Remove('AsList')
89+
8490
if ($accumulateInput.Count) {
8591
if (-not $PSBoundParameters["Depth"]) {
8692
$PSBoundParameters["Depth"] = 100
@@ -94,6 +100,7 @@ function Format-JSON {
94100

95101
$rawJSON.Enqueue((& $baseCommand @PSBoundParameters))
96102
}
103+
97104
if ($rawJSON.Count -gt 1 -or $AsList) {
98105
"[$($rawJSON.ToArray() -join $joiner)]"
99106
} elseif ($rawJSON.Count -eq 1) {

0 commit comments

Comments
 (0)