Skip to content

Commit

Permalink
feat: Get-Interpreter ( Fixes #747 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Feb 7, 2024
1 parent e9b2ca5 commit 6e65b8a
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Commands/Interpreters/Get-Interpreter.ps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function Get-Interpreter
{
<#
.SYNOPSIS
Gets Interpreters
.DESCRIPTION
Gets PipeScript Interpreters
.EXAMPLE
Get-Interpreter
.EXAMPLE
Get-Interpreter -LanguageName "JavaScript"
.NOTES
This command accepts open-ended input.
#>
[Alias('Get-Interpreters','PSInterpreter','PSInterpreters')]
[CmdletBinding(PositionalBinding=$false)]
param(
# The name of one or more languages.
[vbn()]
[string[]]
$LanguageName,

# Any remaining arguments.
[Parameter(ValueFromRemainingArguments)]
[Alias('Args','Arguments','ArgList')]
[PSObject[]]
$ArgumentList,

# Any input object.
[vfp()]
[PSObject]
$InputObject
)

process {
foreach ($arg in $ArgumentList) {
if ($arg -is [string] -and $LanguageName -notcontains $arg) {
$LanguageName += $arg
}
}

$myVerb, $myNoun = $MyInvocation.InvocationName -split '-', 2
if (-not $myNoun) {
$myNoun = $myVerb
$myVerb = "Get"
}

switch ($myVerb) {
Get {
if ($LanguageName) {

$PSInterpreters[$LanguageName]
} else {
$PSInterpreters
}
}
default {
foreach ($arg in $ArgumentList) {
if ($LanguageName) {
$PSInterpreters[$LanguageName]
}
}


}
}

}
}

0 comments on commit 6e65b8a

Please sign in to comment.