Skip to content

Commit 83625eb

Browse files
StartAutomatingStartAutomating
authored andcommitted
Get-MarkdownHelp - Improving Alias Behavior (Fixes #130)
1 parent ee553c9 commit 83625eb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

allcommands.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,19 @@ function Get-MarkdownHelp {
500500
# We decorate that object with the typename `PowerShell.Markdown.Help`.
501501
$helpObj.pstypenames.clear()
502502
$helpObj.pstypenames.add('PowerShell.Markdown.Help')
503+
$IsHelpAboutAlias = $helpObj.Name -ne $gotHelp.Name
504+
$helpObj | Add-Member NoteProperty IsAlias $IsHelpAboutAlias -Force
505+
if ($IsHelpAboutAlias) {
506+
$aliasCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand($gotHelp.Name, 'Alias')
507+
$helpObj | Add-Member NoteProperty AliasCommand $aliasCommand -Force
508+
}
503509

504510
# Then we attach parameters passed to this command to the help object.
505511
# * `-Rename` will become `[string] .Rename`
506512
if ($Rename) {
507513
$helpObj | Add-Member NoteProperty Rename $Rename -Force
514+
} elseif ($IsHelpAboutAlias) {
515+
$helpObj | Add-Member NoteProperty Rename $gotHelp.Name -Force
508516
}
509517

510518
# * `-SectionOrder` will become `[string[]] .SectionOrder`

0 commit comments

Comments
 (0)