Skip to content

Commit

Permalink
Adding PSModuleInfo.Tip(s)/Trick(s) (Fixes #119, Fixes #120)
Browse files Browse the repository at this point in the history
  • Loading branch information
StartAutomating authored and StartAutomating committed Aug 11, 2023
1 parent 8bd6a18 commit afa91f8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Posh.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,18 @@ $posh.ExecutionContext.SessionState.PSVariable.Set("function:$($this.FunctionNam
<Name>Tests</Name>
<ReferencedMemberName>Test</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>Tips</Name>
<ReferencedMemberName>Tip</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>Trick</Name>
<ReferencedMemberName>Tip</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>Tricks</Name>
<ReferencedMemberName>Tip</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>Videos</Name>
<ReferencedMemberName>Video</ReferencedMemberName>
Expand Down Expand Up @@ -2402,6 +2414,42 @@ $this |
Select-Object -Unique
</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>Tip</Name>
<GetScriptBlock>
&lt;#
.SYNOPSIS
Get's a module's tips
.DESCRIPTION
Gets tips and tricks from a module.

Any module can contain `*.tip(s)` or `*.trick(s)` files, of the extensions:

* .md
* .txt
* .ps1
* .psd1
* .json
* .clixml

The collection of tips can be accessed in a Module's .Tip(s) or .Trick(s) properties

#&gt;
if (-not $this.'.Tip') {
$tipCollection =
[PSCustomObject][Ordered]@{
PSTypeName = 'Posh.ExtensionCollection'
Module = $posh
Path = $this.Path | Split-Path
CommandType = 'Posh.Tip.Command'
}

$tipCollection.pstypenames.insert(0,'Posh.Tip.Collection')
$this | Add-Member NoteProperty '.Tip' $tipCollection -Force
}
$this.'.Tip'
</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>Video</Name>
<GetScriptBlock>
Expand Down

0 comments on commit afa91f8

Please sign in to comment.