Skip to content

Commit d5c9816

Browse files
author
James Brundage
committed
feat: Language.Functions/Templates.Unique/Distinct ( Fixes #940 )
1 parent 9aeff0f commit d5c9816

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Distinct = 'Unique'
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<#
2+
.SYNOPSIS
3+
Gets unique Language Functions
4+
.DESCRIPTION
5+
Gets unique functions related to a language.
6+
#>
7+
$distinctCommands = @{}
8+
,@(foreach ($psProperty in $this.PSObject.properties) {
9+
if ($psProperty -isnot [psnoteproperty]) { continue }
10+
if ($psProperty.Value -isnot [Management.Automation.CommandInfo]) { continue }
11+
if (
12+
$psProperty.Value -is [Management.Automation.AliasInfo] -and
13+
(
14+
$distinctCommands[$psProperty.Value.ResolvedCommand] -or
15+
$this.PSObject.Properties[$psProperty.Value.ResolvedCommand.Name]
16+
)
17+
) {
18+
continue
19+
}
20+
$distinctCommands[$psProperty.Value] = $psProperty.Value
21+
$psProperty.Value
22+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Distinct = 'Unique'
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<#
2+
.SYNOPSIS
3+
Gets unique Language Templates
4+
.DESCRIPTION
5+
Gets unique templates related to a language.
6+
#>
7+
$distinctCommands = @{}
8+
,@(foreach ($psProperty in $this.PSObject.properties) {
9+
if ($psProperty -isnot [psnoteproperty]) { continue }
10+
if ($psProperty.Value -isnot [Management.Automation.CommandInfo]) { continue }
11+
if (
12+
$psProperty.Value -is [Management.Automation.AliasInfo] -and
13+
(
14+
$distinctCommands[$psProperty.Value.ResolvedCommand] -or
15+
$this.PSObject.Properties[$psProperty.Value.ResolvedCommand.Name]
16+
)
17+
) {
18+
continue
19+
}
20+
$distinctCommands[$psProperty.Value] = $psProperty.Value
21+
$psProperty.Value
22+
})

0 commit comments

Comments
 (0)