Code Monkey home page Code Monkey logo

ezout's People

Contributors

ninmonkey avatar startautomating avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ezout's Issues

Format-Hashtable should better handle primitive types and enums

Format-Hashtable currently will enumerate all properties of an object without special treatment.

This means:

  1. For [strings], you see a Length property
  2. For [enums], you see a __value property

Neither of these are ideal behaviors.

Even though it would make the function name slightly dishonest:

  • If Format-Hashtable is passed a string, it should return it in single quotes.
  • If Format-Hashtable is passed a primitive, it should return it.
  • If passed an enum, it should return the value inline.
    • If -Safe is not passed, the string should be cast back to the enum type

Format-YAML - seems only the values of properties that are strings get outputted

Import-Excel .\sample.xlsx | Format-YAML

Sample.xlsx

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: 

Out-FormatData should support -Debug

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"

Format-YAML indents and emits too much

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.

Add a Write-FormatControl command

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 { }

running an .ezout.ps1 should output files

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

Format-Markdown

Being able to produce complex markdown formatters opens up entirely new output scenarios.

Format-RichText

Format-RichText should provide similar functionality to the parts SetOutputStyle and ClearOutputStyle.

Format-YAML

Being able to embed YAML formatting can make hierarchical data easy to visualize.

Format-Markdown should escape -Code blocks

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.

Import-TypeView should be able to override the TypeName

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:

  • Typenames can only be legal file names (when, in fact, a typename of https://schmea.org/Thing is valid)
  • There can be only one typename (when, in fact, Write-TypeView supports multiple typenames)
  • Nested directories would be more likely to hit MAX_PATH.

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.

[Enhancement] Prevent Auto Format On Certain Types

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?

Update-FormatData -PrependPath $psScriptRoot\EZOut.format.ps1xml

Example in readme broken (missing a closing ')

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'

[bug] Cannot bind argument to parameter 'InScript' because it is an empty string.

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.

When this line is executed manually in the debugger.
image

Strict mode breaks custom formatting

Set-StrictMode -Off:
image

VS

Set-StrictMode -Version Latest:
image

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 : {}

Format-YAML should handle [enum]s

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.

MyModule.EzFormat.ps1 not generating types.ps1xml

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.

EZOut as a GitHub Action

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

Format-Object Initial Extensions

Format-Object should have extensions that reach parity with and exceed the current selection of parts

These should include:

  • #30 (replaces heatmap)
  • #27 (replaces setoutputstyle/clearoutputstyle)
  • #29
  • #28

Formatting for unknown object properties

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

Format-YAML should be able to limit it's enumeration depth

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.

VS Code Console does not print formatting correctly

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 = $_ } 

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.