Skip to content

Commit

Permalink
Merge pull request #274 from StartAutomating/Posh-Format
Browse files Browse the repository at this point in the history
Posh 0.1.8: Posh Formatting
  • Loading branch information
StartAutomating committed Sep 10, 2023
2 parents 4358f65 + 344d9d7 commit db595a6
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 19 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,15 @@
## Posh 0.1.8: Posh Formatting

* New Formatting:
* Get-Service shows up in color! (#265)
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
* Get-FileHash groups by algorithm and autosizes (#270)
* Improving Formatting:
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
* Improving Enclosure Support in Links (#272)

---

## Posh 0.1.7: Posh Presentation

* New and Improved Formatting:
Expand Down
2 changes: 1 addition & 1 deletion Formatting/Command.format.ps1
Expand Up @@ -5,7 +5,7 @@ Write-FormatView -TypeName System.Management.Automation.CommandInfo, System.Mana
System.Management.Automation.CmdletInfo,
System.Management.Automation.ExternalScriptInfo,
System.Management.Automation.FilterInfo,
System.Management.Automation.FunctionInfo -GroupByProperty CommandType -Property Name, Module -StyleProperty @{
System.Management.Automation.FunctionInfo -GroupByProperty CommandType -Property Name, Source -StyleProperty @{
Name = {
switch -regex ($_.Name)
{
Expand Down
1 change: 1 addition & 0 deletions Formatting/FileHash.format.ps1
@@ -0,0 +1 @@
Write-FormatView -TypeName Microsoft.PowerShell.Commands.FileHashInfo -GroupByProperty Algorithm -Property Hash, Path -AutoSize
9 changes: 9 additions & 0 deletions Formatting/PSEventArgs.format.ps1
@@ -0,0 +1,9 @@
Write-FormatView -TypeName System.Management.Automation.PSEventArgs -Property EventId, SourceId, Time, Sender, SourceArgs, MessageData -AlignProperty ([Ordered]@{
EventID = 'Right'
SourceID = 'Left'
Time = 'Center'
Sender = 'Left'
}) -VirtualProperty @{
EventID = { "" + $_.EventID + ' '}
Time = { $_.Time.ToShortTimeString() }
}
5 changes: 3 additions & 2 deletions Formatting/Posh/Posh.LinkControl.format.ps1
Expand Up @@ -21,12 +21,13 @@ Write-FormatView -TypeName n/a -Name "Posh.Link.Play" -AsControl -Action {
@(
if ($_.enclosure.url -and
$psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) {
" $($psStyle.FormatHyperlink("", $_.enclosure.url)) "
" $($psStyle.FormatHyperlink("(▶ $(@($_.enclosure.type -split '/')[0]))", $_.enclosure.url)) "
}
) -join ''
}

Write-FormatView -TypeName n/a -Name "Posh.Link.Line" -AsControl -Action {
Write-FormatViewExpression -ControlName Posh.Link -ScriptBlock { $_ }
Write-FormatViewExpression -Newline
Write-FormatViewExpression -ControlName Posh.Link.Play -ScriptBlock { $_ }
Write-FormatViewExpression -Newline
}
15 changes: 15 additions & 0 deletions Formatting/Service.format.ps1
@@ -0,0 +1,15 @@
Write-FormatView -Type System.ServiceProcess.ServiceController -Property Status, Name, DisplayName -StyleProperty @{
Status = {
switch ($_.Status) {
Stopped {
'Formatting.Warning'
}
Running {
'Foreground.Green','Bold'
}
default {
'Formatting.Error'
}
}
}
} -AutoSize
180 changes: 178 additions & 2 deletions Posh.format.ps1xml
Expand Up @@ -134,7 +134,7 @@ $script:TreeDepth++;</ScriptBlock>
@(
if ($_.enclosure.url -and
$psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) {
" $($psStyle.FormatHyperlink("", $_.enclosure.url)) "
" $($psStyle.FormatHyperlink("(▶ $(@($_.enclosure.type -split '/')[0]))", $_.enclosure.url)) "
}
) -join ''
</ScriptBlock>
Expand All @@ -154,6 +154,10 @@ $script:TreeDepth++;</ScriptBlock>
<ScriptBlock> $_ </ScriptBlock>
<CustomControlName>Posh.Link</CustomControlName>
</ExpressionBinding>
<ExpressionBinding>
<ScriptBlock> $_ </ScriptBlock>
<CustomControlName>Posh.Link.Play</CustomControlName>
</ExpressionBinding>
<NewLine />
</CustomItem>
</CustomEntry>
Expand Down Expand Up @@ -5394,7 +5398,37 @@ $_ |
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Module</PropertyName>
<PropertyName>Source</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>Microsoft.PowerShell.Commands.FileHashInfo</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.FileHashInfo</TypeName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>Algorithm</PropertyName>
</GroupBy>
<TableControl>
<AutoSize />
<TableHeaders>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Hash</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Path</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
Expand Down Expand Up @@ -5798,6 +5832,60 @@ $_ |
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>System.Management.Automation.PSEventArgs</Name>
<ViewSelectedBy>
<TypeName>System.Management.Automation.PSEventArgs</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>EventId</Label>
<Alignment>Right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Time</Label>
<Alignment>Center</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>Left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<ScriptBlock> "" + $_.EventID + ' '</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>SourceId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock> $_.Time.ToShortTimeString() </ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Sender</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>SourceArgs</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>MessageData</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>System.Management.Automation.PSMemberInfo</Name>
<ViewSelectedBy>
Expand Down Expand Up @@ -6445,6 +6533,94 @@ $module = $_
</CustomEntries>
</CustomControl>
</View>
<View>
<Name>System.ServiceProcess.ServiceController</Name>
<ViewSelectedBy>
<TypeName>System.ServiceProcess.ServiceController</TypeName>
</ViewSelectedBy>
<TableControl>
<AutoSize />
<TableHeaders>
<TableColumnHeader>
<Label>Status</Label>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<!-- {ConditionalStyle:"
switch ($_.Status) {
Stopped {
&apos;Formatting.Warning&apos;
}
Running {
&apos;Foreground.Green&apos;,&apos;Bold&apos;
}
default {
&apos;Formatting.Error&apos;
}
}
"}-->
<TableColumnItem>
<ScriptBlock>
$CellColorValue = $($Script:_LastCellStyle = $($__ = $_;. {
switch ($_.Status) {
Stopped {
'Formatting.Warning'
}
Running {
'Foreground.Green','Bold'
}
default {
'Formatting.Error'
}
}
};$_ = $__);$Script:_LastCellStyle)

$CellColorValue = if ($psStyle) {
@(foreach ($styleProp in $CellColorValue) {
if ($styleProp -match '^\$') {
$ExecutionContext.SessionState.InvokeCommand.InvokeScript($styleProp)
}
elseif ($styleProp -match '\.') {
$targetObject = $psStyle
foreach ($dotProperty in $styleProp -split '(?&lt;!\.)\.') {
if ($targetObject.Item -is [Management.Automation.PSMethodInfo] -or
$targetObject -is [Collections.IDictionary]) {
$targetObject = $targetObject[$dotProperty]
} else {
$targetObject = $targetObject.$dotProperty
}
}
if ($targetObject) {
$targetObject
}
}
else {
$psStyle.$styleProp
}
}) -join ''
}

$output = . {$_.'Status'}
@($CellColorValue; $output; $psStyle.Reset) -join ''
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DisplayName</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>Process.Heatmap</Name>
<ViewSelectedBy>
Expand Down
23 changes: 9 additions & 14 deletions Posh.psd1
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.1.7'
ModuleVersion = '0.1.8'
FormatsToProcess = 'Posh.format.ps1xml'
TypesToProcess = 'Posh.types.ps1xml'
RootModule = 'Posh.psm1'
Expand All @@ -15,20 +15,15 @@
IconURI = 'https://raw.githubusercontent.com/StartAutomating/Posh/main/Assets/Posh.png'
Tags = 'Posh', '.ps1xml', 'Format','Output','Types', 'Colorized', 'Prompt', 'Customization'
ReleaseNotes = @'
## Posh 0.1.7: Posh Presentation
## Posh 0.1.8: Posh Formatting
* New and Improved Formatting:
* Get-Member formatting - Highlighting PowerShell Members (#226)
* Adding Formatting for PSMemberInfo (#246)
* Adding Formatting for MeasureInfo (#247)
* New Blogs
* PowerShell Weekly (#255)
* Host Improvements
* Adding Posh.Host.Cursor (#134, #135, #243, #244, #245, #248, #249, #250, #251, #252, #253, #259, #261)
* Prompt Improvements
* Improving stackable functions (#138) (thanks @mdgrs !)
* Posh.Prompt Tests (#256)
* Adding PSModuleInfo.get_README (#263)
* New Formatting:
* Get-Service shows up in color! (#265)
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
* Get-FileHash groups by algorithm and autosizes (#270)
* Improving Formatting:
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
* Improving Enclosure Support in Links (#272)
---
Expand Down
17 changes: 17 additions & 0 deletions Posh.types.ps1xml
Expand Up @@ -3162,6 +3162,23 @@ $posh.ExecutionContext.SessionState.PSVariable.Set("function:$($this.FunctionNam
</ScriptProperty>
</Members>
</Type>
<Type>
<Name>System.Management.Automation.PSEventArgs</Name>
<Members>
<AliasProperty>
<Name>EventID</Name>
<ReferencedMemberName>EventIdentifier</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>SourceID</Name>
<ReferencedMemberName>SourceIdentifier</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>Time</Name>
<ReferencedMemberName>TimeGenerated</ReferencedMemberName>
</AliasProperty>
</Members>
</Type>
<Type>
<Name>System.Management.Automation.PSModuleInfo</Name>
<Members>
Expand Down
5 changes: 5 additions & 0 deletions Types/PSEventArgs/Alias.psd1
@@ -0,0 +1,5 @@
@{
EventID = 'EventIdentifier'
SourceID = 'SourceIdentifier'
Time = 'TimeGenerated'
}
1 change: 1 addition & 0 deletions Types/PSEventArgs/PSTypeName.txt
@@ -0,0 +1 @@
System.Management.Automation.PSEventArgs
12 changes: 12 additions & 0 deletions docs/CHANGELOG.md
@@ -1,3 +1,15 @@
## Posh 0.1.8: Posh Formatting

* New Formatting:
* Get-Service shows up in color! (#265)
* Get-Event gets a table formatter (and .EventID, .SourceID, .Time) (#268)
* Get-FileHash groups by algorithm and autosizes (#270)
* Improving Formatting:
* Get-Command now shows Source, not Module (#266) ( thanks @ehmiiz ! )
* Improving Enclosure Support in Links (#272)

---

## Posh 0.1.7: Posh Presentation

* New and Improved Formatting:
Expand Down

0 comments on commit db595a6

Please sign in to comment.