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
James Brundage committed Aug 11, 2023
1 parent 0dd88f9 commit 8bd6a18
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Types/PSModuleInfo/Alias.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
Videos = 'Video'
Demos = 'Demo'
Tests = 'Test'
Tips = 'Tip'
Trick = 'Tip'
Tricks = 'Tip'
}
31 changes: 31 additions & 0 deletions Types/PSModuleInfo/get_Tip.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<#
.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
#>
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'

0 comments on commit 8bd6a18

Please sign in to comment.