-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRichModuleInfo.view.ps1
More file actions
49 lines (42 loc) · 1.7 KB
/
RichModuleInfo.view.ps1
File metadata and controls
49 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Write-FormatView -TypeName "System.Management.Automation.PSModuleInfo","Posh.RichModuleInfo" -Property Name, Version, PreRelease, ExportedCommands -VirtualProperty @{
"ExportedCommands" = { $_.ExportedCommands.Values }
}
Write-FormatView -TypeName "System.Management.Automation.PSModuleInfo", "Posh.RichModuleInfo" -Action {
$module = $_
@(
$moduleNameVer = $module.Name + $(
if ($module.Version) {
" [$($module.Version)]"
}
)
Format-Markdown -Heading $moduleNameVer -HeadingSize 1
if ($module.Description) {
Format-Markdown -Heading $module.Description -HeadingSize 2
}
$commandSection =
if ($module.ExportedCommands.Count) {
$sortedByVerb = $module.ExportedCommands.Values |
Where-Object { $_.Verb -and $_.Noun } |
Sort-Object Verb, Noun |
Select-Object Verb, Noun
$sortedByVerb | Format-Markdown -MarkdownTable
}
if ($commandSection) {
$commandLineLength = $commandSection | Measure-Object -Property Length -Maximum | Select-Object -ExpandProperty Maximum
"### Commands"
$commandSection -join [Environment]::NewLine
}
:findAboutText foreach ($culture in "$(Get-Culture)", 'en-us'| Select-Object -Unique) {
$aboutTextFile = $module |
Split-Path |
Join-Path -ChildPath $culture |
Join-Path -ChildPath "About_$module.help.txt"
if (Test-Path $aboutTextFile) {
[IO.File]::ReadAllText("$aboutTextFile")
break
} else {
Write-Verbose "No help.txt file found at $aboutTextFile"
}
}
) -join [Environment]::NewLine
}