Skip to content

Commit c5dcb7d

Browse files
feat: Get-Turtle splatting ( Fixes #121 )
1 parent 87adc75 commit c5dcb7d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Commands/Get-Turtle.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,18 @@ function Get-Turtle {
145145
) {
146146
# If we have arguments,
147147
if ($argList) {
148-
# pass them to the method.
149-
$currentTurtle.$currentMember.Invoke($argList)
148+
# and we have a script method
149+
if ($memberInfo -is [Management.Automation.Runspaces.ScriptMethodData]) {
150+
# set this to the current turtle
151+
$this = $currentTurtle
152+
# and call the script, splatting positional parameters
153+
# (this allows more complex binding, like ValueFromRemainingArguments)
154+
. $currentTurtle.$currentMember.Script @argList
155+
} else {
156+
# Otherwise, we pass the parameters directly to the method
157+
$currentTurtle.$currentMember.Invoke($argList)
158+
}
159+
150160
} else {
151161
# otherwise, just invoke the method with no arguments.
152162
$currentTurtle.$currentMember.Invoke()

0 commit comments

Comments
 (0)