Skip to content

Commit 457b290

Browse files
Add setting the globbing value of parameter from command metadata (#462)
1 parent 233da7a commit 457b290

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

src/platyPS/platyPS.psm1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,6 @@ function ConvertPsObjectsToMamlModel
26072607

26082608
$ParameterObject.DefaultValue = $HelpEntry.defaultValue | normalizeFirstLatter
26092609
$ParameterObject.VariableLength = $HelpEntry.variableLength -eq 'True'
2610-
$ParameterObject.Globbing = $HelpEntry.globbing -eq 'True'
26112610
$ParameterObject.Position = $HelpEntry.position | normalizeFirstLatter
26122611
if ($HelpEntry.description)
26132612
{
@@ -2662,27 +2661,35 @@ function ConvertPsObjectsToMamlModel
26622661
}
26632662
}
26642663

2665-
if ($ExcludeDontShow)
2664+
$hasDontShow = $false
2665+
$hasSupportsWildsCards = $false
2666+
2667+
foreach ($Attribute in $Parameter.Attributes)
26662668
{
2667-
$hasDontShow = $false
2668-
foreach ($Attribute in $Parameter.Attributes)
2669+
if ($ExcludeDontShow)
26692670
{
26702671
if ($Attribute.TypeId.ToString() -eq 'System.Management.Automation.ParameterAttribute' -and $Attribute.DontShow)
26712672
{
26722673
$hasDontShow = $true
26732674
}
26742675
}
26752676

2676-
if ($hasDontShow)
2677+
if ($Attribute.TypeId.ToString() -eq 'System.Management.Automation.SupportsWildcardsAttribute')
26772678
{
2678-
continue
2679+
$hasSupportsWildsCards = $true
26792680
}
26802681
}
26812682

2683+
if ($hasDontShow)
2684+
{
2685+
continue
2686+
}
2687+
26822688
$ParameterObject = New-Object -TypeName Markdown.MAML.Model.MAML.MamlParameter
26832689
$ParameterObject.Name = $Parameter.Name
26842690
$ParameterObject.Required = $Parameter.IsMandatory
26852691
$ParameterObject.PipelineInput = getPipelineValue $Parameter
2692+
$ParameterObject.Globbing = $hasSupportsWildsCards
26862693
# the ParameterType could be just a string in case of remoting
26872694
# or a TypeInfo object, in the regular case
26882695
if ($Session) {

test/Pester/PlatyPs.Tests.ps1

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ Describe 'New-MarkdownHelp' {
146146
}
147147
}
148148

149-
Context 'from external script' {
149+
Context 'from external script' {
150150
It 'fully qualified path' {
151151
$SeedData = @"
152-
<#
152+
<#
153153
.SYNOPSIS
154154
Synopsis Here.
155155
156-
.DESCRIPTION
156+
.DESCRIPTION
157157
Description Here.
158158
159159
.INPUTS
@@ -175,11 +175,11 @@ Write-Host 'Hello World!'
175175
}
176176
It 'relative path' {
177177
$SeedData = @"
178-
<#
178+
<#
179179
.SYNOPSIS
180180
Synopsis Here.
181181
182-
.DESCRIPTION
182+
.DESCRIPTION
183183
Description Here.
184184
185185
.INPUTS
@@ -680,6 +680,31 @@ Get-Alpha [-WhatIf] [[-CCC] <String>] [[-ddd] <Int32>] [<CommonParameters>]
680680
($set2 | Measure-Object).Count | Should Be 1
681681
}
682682
}
683+
684+
Context 'SupportsWildCards attribute tests' {
685+
BeforeAll {
686+
687+
function global:Test-WildCardsAttribute {
688+
param (
689+
[Parameter()]
690+
[SupportsWildcards()]
691+
[string] $Name,
692+
693+
[Parameter()]
694+
[string] $NameNoWildCard
695+
)
696+
}
697+
698+
$file = New-MarkdownHelp -Command 'Test-WildCardsAttribute' -OutputFolder "$TestDrive\NewMarkDownHelp"
699+
$maml = $file | New-ExternalHelp -OutputPath "$TestDrive\NewMarkDownHelp"
700+
$help = Get-HelpPreview -Path $maml
701+
}
702+
703+
It 'sets accepts wildcards property on parameters as expected' {
704+
$help.parameters.parameter | Where-Object { $_.Name -eq 'Name' } | ForEach-Object { $_.globbing -eq 'true'}
705+
$help.parameters.parameter | Where-Object { $_.Name -eq 'NameNoWildCard' } | ForEach-Object { $_.globbing -eq 'false'}
706+
}
707+
}
683708
}
684709
}
685710

0 commit comments

Comments
 (0)