startautomating / ezout Goto Github PK
View Code? Open in Web Editor NEWEZOut is a PowerShell module to help take the pain out of writing format and types XML
Home Page: https://ezout.start-automating.com
License: MIT License
EZOut is a PowerShell module to help take the pain out of writing format and types XML
Home Page: https://ezout.start-automating.com
License: MIT License
An animated gif if great for a README, and a waste of space in Install-Module.
This will need to be fixed in the workflow.
VS
Set-StrictMode -Version Latest:
Error details:
PSMessageDetails :
Exception : System.Management.Automation.RuntimeException: The variable '$EZOut_ClearOutputStyle' cannot be retrieved because it has not been set.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\Operations\MiscOps.cs:line 1664
at <ScriptBlock>(Closure , FunctionContext )
at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1
variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\runtime\CompiledScriptBlock.cs:line 1270
at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe
outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\lang\scriptblock.cs:line 1043
at Microsoft.PowerShell.Commands.PSPropertyExpression.GetValue(PSObject target, Boolean eatExceptions) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\FormatAndOutput\common\Utilities\Mshexpression.cs:line 352
TargetObject : EZOut_ClearOutputStyle
CategoryInfo : InvalidOperation: (EZOut_ClearOutputStyle:String) [], RuntimeException
FullyQualifiedErrorId : VariableIsUndefined
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
Write-EZFormatFile defaults to generating a file that will not run with Invoke-Expression. This prevents the action from working without an EZOut file.
Hi,
I cannot get the types file generated. I suspect it is because of the get-item
instead of Get-ChildItem
.
Am I right or I don't understand something?
Thanks
EDIT : Nope, doesn't work.
I have one Service.types.ps1 in the Types Folder, next to the psd1 and EzFormat.ps1 file.
PipeScript can simplify implementation of a method or property file, and since we don't want types.ps1xml files to contain the original source, Import-TypeView/-FormatView should ignore PipeScript source generators
Source Generators match a Regex:
\.ps1{0,1}\.(?<ext>[^.]+$)
System.Diagnostics.Format.ps1 uses the heatmap part.
The fact that the bug has existing for this long shows how rarely selections sets are used.
In order to simplify embedding YAML, Format-YAML should support an -Indent level
Being able to embed YAML formatting can make hierarchical data easy to visualize.
EZOut should be available as a GitHub action.
This action should run any .ezout|format files, and, if a Formatting or Types directory exists and an .ezeout|formatfile does not, it should automatically generate and run an .ezout file.
Changes should be checked back in with a customizable -GitUserEmail and -CommitMessage
The output does not print correctly in the integrated console for either version 5.1 or 7.0.
Write-FormatView -Property Number, IsEven, IsOdd -AutoSize -ColorRow {
if ($_.N % 2) { "#ff0000" } else { "#0f0" }
} -VirtualProperty @{
IsEven = { -not ($_.N % 2) }
IsOdd = { ($_.N % 2) -as [bool] }
} -AliasProperty @{
Number = 'N'
} -TypeName N |
Out-FormatData |
Add-FormatData
1..5 | Foreach-Object { [PSCustomObject]@{PSTypeName = 'N'; N = $_ }
Format-Hashtable currently will enumerate all properties of an object without special treatment.
This means:
Neither of these are ideal behaviors.
Even though it would make the function name slightly dishonest:
Import-TypeView is not correctly generating hidden properties from files beginning with .
The sample is missing the single quote to close -TypeName parameter.
Current
Write-FormatView -TypeName 'System.Management.ManagementObject#root\cimv2\Win32_VideoController
Should be
Write-FormatView -TypeName 'System.Management.ManagementObject#root\cimv2\Win32_VideoController'
Currently there are (at least) 2 ways to write a format control:
Write-FormatView -TypeName typename -AsControl -Name ControlName -Action { }
This requires both an -AsControl
switch and a -TypeName
to be specified, although the -TypeName
is completely ignored.
Write-FormatCustomView -AsControl -Name ControlName -Action { }
This is better, but still not much shorter.
Why not have this as the preferred method:
Write-FormatControl -Name ControlName -Action { }
Format-RichText should provide similar functionality to the parts SetOutputStyle and ClearOutputStyle.
When -Debug is passed to Out-FormatData, Out-FormatData should not replace command formatters with their embedded versions.
This will make the resulting formatter "debuggable"
Part of#24
There should be a Format-Object command, which calls any extensions of itself or passes an -InputObject thru
I want to format the outputs of my PSJwt PowerShell module
Default the following is returned:
$Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
ConvertFrom-JWT -Token $Token
Header Payload
------ -------
@{Env=Demo; typ=JWT; alg=HS256} @{iat=1393268893; Demo=Encode Access Token; FirstName=Stefan; exp=1393286893; LastName=Stranger}
I would like to have a default list output of the Payload property.
Example:
$Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
ConvertFrom-JWT -Token $Token | Select-Object -ExpandProperty Payload
iat : 1393268893
Demo : Encode Access Token
FirstName : Stefan
exp : 1393286893
LastName : Stranger
So if the user runs:
$Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
ConvertFrom-JWT -Token $Token | Select-Object -Property Payload
It should return:
iat : 1393268893
Demo : Encode Access Token
FirstName : Stefan
exp : 1393286893
LastName : Stranger
End when the user runs:
$Token = 'eyJFbnYiOiJEZW1vIiwidHlwIjoiSldUIiwiYWxnIjoiSFMyNTYifQ.eyJpYXQiOiIxMzkzMjY4ODkzIiwiRGVtbyI6IkVuY29kZSBBY2Nlc3MgVG9rZW4iLCJGaXJzdE5hbWUiOiJTdGVmYW4iLCJleHAiOiIxMzkzMjg2ODkzIiwiTGFzdE5hbWUiOiJTdHJhbmdlciJ9.JFJVUaBIUJmHQUawkK1dH5Iie8tSTTXKFbZZka3_k7Y'
ConvertFrom-JWT -Token $Token | Select-Object -Property Header
It should output:
Env : Demo
typ : JWT
alg : HS256
The challenge is that I don't know which properties are created in the JWT so I cannot create a format file containing the properties of the object.
How can EzOut be using in above examples?
Regards,
Stefan Stranger
Currently, if the code in a codeblock contains tags, Format-Markdown will not escape these tags.
This leads to some rendering engines (like GitHub Pages) to not properly display the examples.
Format-Heatmap should replace the Heatmap part
Currently, Format-YAML displays an enum as it's numerical value in a nested object.
It should display the enum's value as a string instead.
Import-Excel .\sample.xlsx | Format-YAML
Only prints the Category
. The "numbers" don't get emitted for the others.
- OrderId:
Category: Cosmetics
Sales:
Quantity:
Discount:
- OrderId:
Category: Grocery
Sales:
Quantity:
Discount:
- OrderId:
Category: Apparels
Sales:
Quantity:
Discount:
- OrderId:
Category: Electronics
Sales:
Quantity:
Discount:
- OrderId:
Category: Electronics
Sales:
Quantity:
Discount:
- OrderId:
Category: Apparels
Sales:
Quantity:
Discount:
- OrderId:
Category: Electronics
Sales:
Quantity:
Discount:
- OrderId:
Category: Cosmetics
Sales:
Quantity:
Discount:
- OrderId:
Category: Grocery
Sales:
Quantity:
Discount:
- OrderId:
Category: Grocery
Sales:
Quantity:
Discount:
Format-YAML will always indent non-string values by two extra characters.
Also, when input is not piped in, Format-YAML emits an empty string after the output.
The following statement fails at Out-FormatData
Write-FormatView -AsList -TypeName 'test' -Property 'IsMultiSelect', 'Values' | Out-FormatData | Add-FormatData
This seems to happen specifically when using Values
as one of the parameter.
(Values2 won't create any issues)
Here is the error
Cannot bind argument to parameter 'InScript' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\EZOut\1.8.3.1\Out-FormatData.ps1:165 char:21
+ ... & $FindUsedParts -FromModule $modulesThatMayHaveParts
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (System.Xml.XmlElement:XmlElement) [], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed
The line that fail is :
& $FindUsedParts -FromModule $modulesThatMayHaveParts
The $FindUserParts
want an $InScript String, which is not provided.
Since objects can have circular references (and almost everything has properties), passing real .NET objects to Format-YAML can sometimes lead to stack overflows.
As such, Format-YAML should be able to limit it's enumeration depth with -Depth
If using Format-YAML in your own formatter, you are encouraged to use the PowerShell automatic variable:
$FormatEnumerationLimit
to limit the -Depth.
Being able to produce complex markdown formatters opens up entirely new output scenarios.
If a function is found in a formatter, and it is an extension of Format-Object, it should be assumed that the extension is embeddable.
It escapes | as `|. It should be |
Additionally, Format-Markdown does not split on the right table entries (it should avoid escaped ones)
Since hashtables provide an easy to copy/paste format for nested objects within PowerShell, EZOut should be able to format any object as a hashtable.
Without files being emitted, the GitHub Action for EZOut fails to see changes.
Additionally, returning the created files will give interactive feedback for those running an .\ezout.ps1
The current design means that a very long type name will lead to a very long directory name.
This limits things in a few ways:
https://schmea.org/Thing
is valid)Therefore:
Import-TypeView should support a TypeName.txt file in the directory
This file should allow N typenames to be defined that override the directory name.
It commits changes, but does not push them.
It would be convenient to be able to pick and choose which formatters we want to be applied in the below code. For instance, I'm not into tree view for FileInfo
. I really like the [xml]
formatter though. Maybe something like ModuleArguments
?
Line 96 in 21cf887
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.