Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from StartAutomating/More-Posh
More posh
- Loading branch information
Showing
24 changed files
with
3,030 additions
and
1,407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
Write-FormatView -TypeName Posh.RSS.Article -Action { | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Link | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Link | ||
Write-FormatViewExpression -If { $_.DatePublished -is [datetime] } -ScriptBlock { | ||
" ($($_.DatePublished.ToShortDateString())) " | ||
} | ||
Write-FormatViewExpression -If { $_.Enclosure } -ScriptBlock { $_ } -ControlName Posh.Link.Play | ||
|
||
} -GroupByProperty Source | ||
|
||
Write-FormatView -TypeName Posh.RSS.Article -Property Title, Link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,99 @@ | ||
Write-FormatView -TypeName System.Type -Property FullName, BaseType, IsPublic, IsSerializable -AutoSize | ||
|
||
Write-FormatView -TypeName System.Type -Action { | ||
Write-FormatView -TypeName n/a -AsControl -Name TypeInheritanceControl -Action { | ||
Write-FormatViewExpression -Newline | ||
Write-FormatViewExpression -ScriptBlock { '-' * ($Host.UI.RawUI.BufferSize.Width - 1) } | ||
Write-FormatViewExpression -ScriptBlock { ' ' * 1 } | ||
Write-FormatViewExpression -ForegroundColor 'Verbose' -ScriptBlock { $_ } -ControlName TypeNameControl | ||
Write-FormatViewExpression -ScriptBlock { ' ' * 1 } | ||
Write-FormatViewExpression -Style 'Formatting.Verbose' -ScriptBlock { $_ } -ControlName TypeNameControl | ||
Write-FormatViewExpression -ScriptBlock { ' ' * 1 } | ||
Write-FormatViewExpression -If { $_.BaseType -and -not $_.IsValueType } -ScriptBlock { | ||
':' | ||
} | ||
Write-FormatViewExpression -If { $_.BaseType -and -not $_.IsValueType -and $_.BaseType -ne [Object] } -Property BaseType -ControlName TypeBase | ||
Write-FormatViewExpression -If { $_.GetInterfaces() } -ScriptBlock { $_.GetInterfaces() | Sort-Object Name} -Enumerate -ControlName TypeBase | ||
} -GroupLabel 'Type Summary' -GroupByScript { '| Format-Custom -View System.Type.Full for more'} -Name System.Type.Summary | ||
|
||
Write-FormatView -TypeName System.Type -Action { | ||
Write-FormatViewExpression -Newline | ||
Write-FormatViewExpression -ScriptBlock { '-' * ($Host.UI.RawUI.BufferSize.Width - 1) } | ||
Write-FormatViewExpression -ScriptBlock { ' ' * 1 } | ||
Write-FormatViewExpression -ForegroundColor 'Verbose' -ScriptBlock { $_ } -ControlName TypeNameControl | ||
Write-FormatViewExpression -ScriptBlock { ' ' * 1 } | ||
Write-FormatViewExpression -If { $_.BaseType -and -not $_.IsValueType -and $_.BaseType -ne [Object] } -ScriptBlock { | ||
':' | ||
} | ||
Write-FormatViewExpression -If { $_.BaseType -and -not $_.IsValueType -and $_.BaseType -ne [Object] } -Property BaseType -ControlName TypeBase | ||
Write-FormatViewExpression -If { $_.GetInterfaces() } -ScriptBlock { $_.GetInterfaces() | Sort-Object Name} -Enumerate -ControlName TypeBase | ||
Write-FormatViewExpression -ScriptBlock { '=' * ($Host.UI.RawUI.BufferSize.Width - 1) } | ||
} | ||
|
||
Write-FormatViewExpression -If { $_.GetConstructors('Instance,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Constructors:' | ||
} | ||
Write-FormatViewExpression -If { $_.GetConstructors('Instance,Public') } -ScriptBlock { | ||
$_.GetConstructors('Instance,Public') | ||
} -Enumerate -ControlName TypeMethodControl | ||
Write-FormatViewExpression -If { $_.GetEvents('Instance,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Events:' | ||
} | ||
Write-FormatViewExpression -If { $_.GetEvents('Instance,Public') } -ScriptBlock { | ||
$_.GetEvents('Instance,Public') | Sort-Object Name | ||
} -Enumerate -ControlName TypeEventControl | ||
Write-FormatViewExpression -If { $_.GetProperties('Static,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Static Properties:' | ||
|
||
$TypeGrouping = [Ordered]@{ | ||
GroupByScript = { | ||
" | ||
... | Format-Custom -View Full # To show public and private members | ||
... | Format-Custom -View Public # To show public members | ||
... | Format-Custom -View Private # To show private members | ||
... | Format-Custom -View Interfaces # To show interfaces | ||
" | ||
} | ||
Write-FormatViewExpression -If { $_.GetProperties('Static,Public')} -ScriptBlock { | ||
$_.GetProperties('Static,Public') | Sort-Object Name | ||
} -Enumerate -ControlName TypePropertyControl | ||
Write-FormatViewExpression -If { $_.GetProperties('Instance,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Properties:' | ||
} | ||
|
||
Write-FormatView -TypeName System.Type -Action { | ||
Write-FormatViewExpression -ControlName TypeInheritanceControl -ScriptBlock { $_ } | ||
} -GroupLabel 'Type Inheritance' @TypeGrouping -Name Inheritance | ||
|
||
Write-FormatView -TypeName System.Type -Action { | ||
Write-FormatViewExpression -ControlName TypeInheritanceControl -ScriptBlock { $_ } | ||
Write-FormatViewExpression -If { $_.GetInterfaces() } -ScriptBlock { $_.GetInterfaces() | Sort-Object Name} -Enumerate -ControlName TypeInterfaceControl | ||
} -GroupLabel 'Type Inheritance' @TypeGrouping -Name Interfaces | ||
|
||
foreach ($viewName in 'Public','Private','Full') { | ||
$bindingFlags = | ||
switch ($viewName) { | ||
Public { | ||
'Public' | ||
} | ||
Private { | ||
'NonPublic' | ||
} | ||
Full { | ||
'Public,NonPublic' | ||
} | ||
} | ||
$assignView = [ScriptBlock]::Create(" | ||
`$_ | | ||
Add-Member NoteProperty '.View' '$viewName' -PassThru -Force | | ||
Add-Member NoteProperty '.BindingFlags' ([Reflection.BindingFlags]'$bindingFlags') -Force | ||
") | ||
|
||
Write-FormatView -TypeName System.Type -Action { | ||
Write-FormatViewExpression -If $assignView -ScriptBlock { "" } | ||
|
||
Write-FormatViewExpression -ControlName TypeInheritanceControl -ScriptBlock { $_ } | ||
|
||
Write-FormatViewExpression -If { | ||
$_.GetInterfaces() | ||
} -ScriptBlock { | ||
$_.GetInterfaces() | Sort-Object Name | ||
} -Enumerate -ControlName TypeInterfaceControl | ||
|
||
Write-FormatViewExpression -ControlName TypeConstructorsControl -ScriptBlock { | ||
if ($_.'.BindingFlags') { | ||
@{Type=$_;BindingFlags="Instance,$($_.'.BindingFlags')"} | ||
} else { | ||
$_ | ||
} | ||
} | ||
Write-FormatViewExpression -If { $_.GetProperties('Instance,Public')} -ScriptBlock { | ||
$_.GetProperties('Instance,Public') | Sort-Object Name | ||
} -Enumerate -ControlName TypePropertyControl | ||
Write-FormatViewExpression -If { $_.GetMethods('Static,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Static Methods:' | ||
|
||
Write-FormatViewExpression -ControlName TypeEventsControl -ScriptBlock { | ||
if ($_.'.BindingFlags') { | ||
@{Type=$_;BindingFlags="Instance,$($_.'.BindingFlags')"} | ||
} else { | ||
$_ | ||
} | ||
} | ||
Write-FormatViewExpression -If { $_.GetMethods('Static,Public') } -ScriptBlock { | ||
$_.GetMethods('Static,Public') | Sort-Object Name | Where-Object { -not $_.IsSpecialName } | ||
} -Enumerate -ControlName TypeMethodControl | ||
Write-FormatViewExpression -If { $_.GetMethods('Instance,Public') } -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Methods:' | ||
|
||
Write-FormatViewExpression -ControlName TypePropertiesControl -ScriptBlock { | ||
if ($_.'.BindingFlags') { | ||
@{Type=$_;BindingFlags="$($_.'.BindingFlags')"} | ||
} else { | ||
$_ | ||
} | ||
} | ||
Write-FormatViewExpression -If { $_.GetMethods('Instance,Public') } -ScriptBlock { | ||
$_.GetMethods('Instance,Public') | Sort-Object Name | Where-Object { -not $_.IsSpecialName } | ||
} -Enumerate -ControlName TypeMethodControl | ||
} -Name System.Type.Full | ||
|
||
Write-FormatViewExpression -ControlName TypeMethodsControl -ScriptBlock { | ||
if ($_.'.BindingFlags') { | ||
@{Type=$_;BindingFlags="$($_.'.BindingFlags')"} | ||
} else { | ||
$_ | ||
} | ||
} | ||
} -Name "$ViewName" -GroupLabel "Type $ViewName" @TypeGrouping | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$getConstructors = { | ||
if ($_ -is [Type]) { | ||
$_.GetConstructors('Instance,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetConstructors($_.BindingFlags) | ||
} | ||
} | ||
Write-FormatControl -Name TypeConstructorsControl -Action { | ||
Write-FormatViewExpression -If $getConstructors -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Constructors:' | ||
} | ||
Write-FormatViewExpression -If $getConstructors -ScriptBlock $getConstructors -Enumerate -ControlName TypeMethodControl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$getEvents = { | ||
if ($_ -is [Type]) { | ||
$_.GetEvents('Instance,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetEvents($_.BindingFlags) | ||
} | ||
} | ||
|
||
Write-FormatControl -Name TypeEventsControl -Action { | ||
Write-FormatViewExpression -If $getEvents -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Events:' | ||
} | ||
Write-FormatViewExpression -If $getEvents -ScriptBlock $getEvents -Enumerate -ControlName TypeEventControl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Write-FormatView -Action { | ||
Write-FormatViewExpression -Newline | ||
Write-FormatViewExpression -ScriptBlock { ' *' } | ||
Write-FormatViewExpression -ControlName TypeNameControl -ScriptBlock {$_ } -Style 'Foreground.Cyan', 'Bold' | ||
} -TypeName n/a -Name TypeInterfaceControl -AsControl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
Write-FormatView -Action { | ||
Write-FormatViewExpression -If { $_.N -gt 0} -ScriptBlock { ', ' } | ||
Write-FormatViewExpression -Property ParameterType -ControlName TypeNameControl -Style 'Formatting.Verbose' | ||
Write-FormatViewExpression -ScriptBlock { '$' + $_.Name } -Style 'Formatting.Warning' | ||
Write-FormatViewExpression -ScriptBlock { ' ' } | ||
Write-FormatViewExpression -Property ParameterType -ControlName TypeNameControl -Style 'Foreground.Cyan','Bold' | ||
Write-FormatViewExpression -ScriptBlock { '$' + $_.Name + ' ' } -Style 'Formatting.Warning' -If {$_.Name } | ||
} -TypeName TypeMethodParameterControl -Name TypeMethodParameterControl -AsControl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$getStaticMethods = { | ||
if ($_ -is [Type]) { | ||
$_.GetMethods('Static,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetMethods("Static,$($_.BindingFlags)") | ||
} | ||
} | ||
|
||
$getInstanceMethods = { | ||
if ($_ -is [Type]) { | ||
$_.GetMethods('Instance,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetMethods("Instance,$($_.BindingFlags)") | ||
} | ||
} | ||
|
||
Write-FormatControl -Name TypeMethodsControl -Action { | ||
Write-FormatViewExpression -If $getStaticMethods -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Static Methods:' | ||
} | ||
Write-FormatViewExpression -If $getStaticMethods -ScriptBlock $getStaticMethods -Enumerate -ControlName TypeMethodControl | ||
Write-FormatViewExpression -If $getInstanceMethods -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Methods:' | ||
} | ||
Write-FormatViewExpression -If $getInstanceMethods -ScriptBlock $getInstanceMethods -Enumerate -ControlName TypeMethodControl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$getStaticProperties = { | ||
if ($_ -is [Type]) { | ||
$_.GetProperties('Static,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetProperties("Static,$($_.BindingFlags)") | ||
} | ||
} | ||
|
||
$getInstanceProperties = { | ||
if ($_ -is [Type]) { | ||
$_.GetProperties('Instance,Public') | ||
} elseif ($_.Type -and $_.BindingFlags) { | ||
$_.Type.GetProperties("Instance,$($_.BindingFlags)") | ||
} | ||
} | ||
|
||
Write-FormatControl -Name TypePropertiesControl -Action { | ||
Write-FormatViewExpression -If $getStaticProperties -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Static Properties:' | ||
} | ||
Write-FormatViewExpression -If $getStaticProperties -ScriptBlock $getStaticProperties -Enumerate -ControlName TypePropertyControl | ||
Write-FormatViewExpression -If $getInstanceProperties -ScriptBlock { | ||
[Environment]::NewLine + ('#' * 3) + ' Properties:' | ||
} | ||
Write-FormatViewExpression -If $getInstanceProperties -ScriptBlock $getInstanceProperties -Enumerate -ControlName TypePropertyControl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Write-FormatView -TypeName System.Version -Action { | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName VersionControl | ||
} |
Oops, something went wrong.