-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Bug - Multiple TableRowEntry
Piped to Write-FormatTableView
No Label
#235
Comments
I appreciate your interest in EZOut and its implementation. I'm also at a bit of a loss for exactly what your expectations are for the codeblock above? What are you expecting? As designed - I would expect If you were to pipe in multiple items as it stands, I believe the lack of a corresponding -Condition would make the Perhaps this is partially because is a different from what I'd consider a "normal" implementation of EZOut (see the /Types or /Formats directory structure in many modules, including this one). Perhaps this is because I'm missing some context about this scenario. I'm happy to hop on a call to figure out what's going on. Please provide a little more context / repro so we can get things going. |
Well that is embarrassing, James. I am very sorry as I am seeing I provided a terrible example. :-) I've since updated my Issue with a full repro and a screenshot of the issue. I'm doing it this way so I can have multiple |
@mattcargile thanks for the additional context. A few thoughts and questions remain. I'm still not quite sure why you'd do this in multiple entries. FWIW, I think at this point it is pretty clear that I wonder if the fact that it's named Name is a cause for weirdness. I'll try to debug later to see if I can spot what's truly wrong. Additional high-level implementation thoughts below: -AliasProperties aren't exactly a good idea (in formatters alone)This was recognized pretty early on, when people saw the formatting for Get-Process and could not access the properties that the table suggested existed. In general, I believe it's better to create an AliasProperty in a .types.ps1xml, too. This way, the property actually exists when the user goes looking for it (instead of wondering while This is super easy. Just create a directory for your type, and then make an Alias.psd1 file. The key is the alias, the value is what it is aliased to. Then run Import-TypeView on that directory and you'll be good to go. EZOut works best with modulesIt might be my bad in documentation, but I believe you really should be using EZOut within a module structure. Here's a step-by-step "get up and running" checklist.
The more I've dealt with both types and formatters, the more I've come to see and respect that types files are the more useful of the pair. Last but not leastIt seems like you're making a nice humanized file formatter. This is great, and if you wanted to, you could just modify the formatter in Posh to support a humanized form of the file access time. There's already code in there to allow use of terminal-icons, so, why not add support for conditional humanization, too? Point is: whenever you've got it sorted enough, I'd happily take a PR for Posh. |
I want I thought it would make the logic simpler with four different entries especially since the Additionally,
I don't think so. You can see
I'd agree with this sentiment too. The alias properties aren't really aliases, it is just a way to force the headers to work. The only "real" use of the Alias Propery is to make use of the
I've got a
I did look at that formatter while I was creating my P.S. I'll see if I can hook up the debugger and play with it too. I assume the issue is the |
Deserialized objects can indeed be annoying. When dealing with them, I find it's best to -match on the typename (which will work for both real and deserialized).
Eh, kinda/sorta / not really. Since the .Length is already a -VirtualProperty, it wouldn't be too much difficulty to check to see if humanizer is loaded and then use the humanized version. Much like with how it treats TerminalIcons (if it's loaded, TerminalIcons will be preferred over Posh's icons).
Thanks for looking more into it. I'd love to figure out what the bug is here and try to include the fix in the current batch. Fair warning on debugging: While the commands in EZOut are debuggable, .format.ps1xml files cannot be directly debugged. You can have a formatter that calls a command and break in there, but you can't put a breakpoint in a .format.ps1xml. The same holds true for .types.ps1xml. However, in either case, building the formatters and types in individual files will make them much easier to debug (since you can put a breakpoint in your scripts and run them directly with the same input). |
Right. I wanted to avoid the
I'd agree with that maybe I'll look at it after I figure out this issue.
So I did some debugging. I believe the issue is that
For instance, I think the
It does seem fairly challenging to get right and the user has the opportunity to "break" it by not picking the same properties, as you probably know. Additionally, shouldn't the below code have write-formatTableView -Property Name -Width 70 -ViewTypeName myview -AliasProperty @{ Name = 'nm' } EZOut/Commands/Format.PS1XML/Write-FormatTableView.ps1 Lines 291 to 303 in 82ea997
It feels like the AliasProperty logic should be reversed? Or do I need to write the code like the below?
write-formatTableView -Property nm -Width 70 -ViewTypeName myview -AliasProperty @{ nm = 'Name' } |
@mattcargile just checked in a fix for the pipeline behavior you observed. Please check out the branch or pull down the docker image and give it a try. As far as the
|
Latest commits fixed it. |
Description
When piping
[pscustomobject]
s and binding by property name, theLabel
node is missing onTableColumnHeader
causing certain formatting issues like theLabel
ends up being the plain text of the[scriptblock]
.I'd expect the
Label
to match name in-Property
[array]
if noAliasProperty
. I assume the last[pscustomobject]
in the[array]
will determine theTableColumnHeader
structure.Workaround
Use
-AliasProperty @{ Name = 'Name'; Mode = 'Mode'}
on the last[pscustomobject]
in the@()
.Notes
I don't think
Write-FormatListView
shows this same behavior. Loving getting my formatting set up in mybuild.ps1
. Thanks for the time on this!Reproducable Steps
Links
N/A
The text was updated successfully, but these errors were encountered: