Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions InvokeHelperTest/public/InvokeCommandList.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ function InvokeHelperTest_InvokeCommandAlias_Get{
Assert-AreEqual -Expected 'echo "this is a sample command2"' -Presented $result["commandAlias2"].Command
}

function InvokeHelperTest_InvokeCommandAlias_Get_With_Tag{

Set-InvokeCommandAlias -Alias "commandAlias" -Command 'echo "this is a sample command"' -Tag Module1
Set-InvokeCommandAlias -Alias "commandAlias2" -Command 'echo "this is a sample command2"' -Tag Module2

$result = Get-InvokeCommandAliasList -Tag Module1

Assert-AreEqual -Expected 'echo "this is a sample command"' -Presented $result["commandAlias"].Command

Set-InvokeCommandAlias -Alias "commandAlias3" -Command 'echo "this is a sample command3"' -Tag Module1

$result = Get-InvokeCommandAliasList -Tag Module1

Assert-Count -Expected 2 -Presented $result
Assert-AreEqual -Expected 'echo "this is a sample command"' -Presented $result["commandAlias"].Command
Assert-AreEqual -Expected 'echo "this is a sample command3"' -Presented $result["commandAlias3"].Command

}

function InvokeHelperTest_InvokeCommandAlias_Reset{

Reset-InvokeCommandAlias
Expand Down
15 changes: 13 additions & 2 deletions public/InvokeCommandList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ Get the Command list active in the module
function Get-InvokeCommandAliasList{
[CmdletBinding()]
[OutputType([hashtable])]
param()
param(
[Parameter()][string]$Tag
)

if($script:InvokeCommandList -eq $null -or $script:InvokeCommandList.Count -eq 0){
return $null
}

$ret = @{}

if(-Not [string]::IsNullOrWhiteSpace($Tag)){
$validKeys = $script:InvokeCommandList.Keys | Where-Object { $script:InvokeCommandList.$_.Tag -eq $Tag }
$validKeys | ForEach-Object { $ret.$_ = $script:InvokeCommandList.$_ }
} else {
return $script:InvokeCommandList
$ret = $script:InvokeCommandList
}

return $ret

} Export-ModuleMember -Function Get-InvokeCommandAliasList

function Test-InvokeCommandAlias{
Expand Down
Loading