From fdfe686c569dab4ff038f2988b173f6dc9240519 Mon Sep 17 00:00:00 2001 From: mdgrs <81177095+mdgrs-mei@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:24:40 +0900 Subject: [PATCH 1/2] Add ArgumentList parameter to ScriptBlock entries --- module/PowerShellRun/Private/ScriptRegistry.ps1 | 8 ++++---- module/PowerShellRun/Public/Add-PSRunScriptBlock.ps1 | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/module/PowerShellRun/Private/ScriptRegistry.ps1 b/module/PowerShellRun/Private/ScriptRegistry.ps1 index 5729d0d..437dc60 100644 --- a/module/PowerShellRun/Private/ScriptRegistry.ps1 +++ b/module/PowerShellRun/Private/ScriptRegistry.ps1 @@ -34,10 +34,10 @@ class ScriptRegistry : EntryRegistry { $this.scriptBlockCallback = { $result = $args[0].Result - $scriptBlock = $args[0].ArgumentList + $scriptBlock, $argumentList = $args[0].ArgumentList if ($result.KeyCombination -eq $script:globalStore.firstActionKey) { - & $scriptBlock + & $scriptBlock @argumentList } elseif ($result.KeyCombination -eq $script:globalStore.secondActionKey) { $scriptBlock.ToString() } elseif ($result.KeyCombination -eq $script:globalStore.thirdActionKey) { @@ -79,7 +79,7 @@ class ScriptRegistry : EntryRegistry { } } - [void] AddScriptBlock($scriptBlock, $icon, $name, $description, $preview, [EntryGroup]$entryGroup) { + [void] AddScriptBlock($scriptBlock, $argumentList, $icon, $name, $description, $preview, [EntryGroup]$entryGroup) { if (-not $this.isEnabled) { Write-Warning -Message '"Script" category is disabled.' return @@ -98,7 +98,7 @@ class ScriptRegistry : EntryRegistry { $entry.UserData = @{ ScriptBlock = $this.scriptBlockCallback - ArgumentList = $scriptBlock + ArgumentList = $scriptBlock, $argumentList } if ($entryGroup) { diff --git a/module/PowerShellRun/Public/Add-PSRunScriptBlock.ps1 b/module/PowerShellRun/Public/Add-PSRunScriptBlock.ps1 index ea69155..28b5d6a 100644 --- a/module/PowerShellRun/Public/Add-PSRunScriptBlock.ps1 +++ b/module/PowerShellRun/Public/Add-PSRunScriptBlock.ps1 @@ -8,6 +8,9 @@ Adds a ScriptBlock as an entry that can be invoked on selection. The entry belon .PARAMETER ScriptBlock The ScriptBlock that is invoked on selection. +.PARAMETER ArgumentList +The arguments that are passed to the ScriptBlock. + .PARAMETER Icon The icon string. @@ -43,6 +46,9 @@ function Add-PSRunScriptBlock { [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] [ScriptBlock]$ScriptBlock, + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Object[]]$ArgumentList, + [Parameter(ValueFromPipelineByPropertyName = $true)] [String]$Icon, @@ -61,6 +67,6 @@ function Add-PSRunScriptBlock { process { $registry = $script:globalStore.GetRegistry('ScriptRegistry') - $registry.AddScriptBlock($ScriptBlock, $Icon, $Name, $Description, $Preview, $EntryGroup) + $registry.AddScriptBlock($ScriptBlock, $ArgumentList, $Icon, $Name, $Description, $Preview, $EntryGroup) } } From 7b3ec07e22d937a756eae432b24ca73511cae213 Mon Sep 17 00:00:00 2001 From: mdgrs <81177095+mdgrs-mei@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:52:14 +0900 Subject: [PATCH 2/2] Add ArgumentList parameter to script file entries --- module/PowerShellRun/Private/ScriptRegistry.ps1 | 8 ++++---- module/PowerShellRun/Public/Add-PSRunScriptFile.ps1 | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/module/PowerShellRun/Private/ScriptRegistry.ps1 b/module/PowerShellRun/Private/ScriptRegistry.ps1 index 437dc60..76b0147 100644 --- a/module/PowerShellRun/Private/ScriptRegistry.ps1 +++ b/module/PowerShellRun/Private/ScriptRegistry.ps1 @@ -60,10 +60,10 @@ class ScriptRegistry : EntryRegistry { $this.scriptFileCallback = { $result = $args[0].Result - $filePath = $args[0].ArgumentList + $filePath, $argumentList = $args[0].ArgumentList if ($result.KeyCombination -eq $script:globalStore.firstActionKey) { - & $filePath + & $filePath @argumentList } elseif ($result.KeyCombination -eq $script:globalStore.secondActionKey) { & $script:globalStore.defaultEditorScript $filePath } elseif ($result.KeyCombination -eq $script:globalStore.thirdActionKey) { @@ -109,7 +109,7 @@ class ScriptRegistry : EntryRegistry { } } - [void] AddScriptFile($filePath, $icon, $name, $description, $preview, [EntryGroup]$entryGroup) { + [void] AddScriptFile($filePath, $argumentList, $icon, $name, $description, $preview, [EntryGroup]$entryGroup) { if (-not $this.isEnabled) { Write-Warning -Message '"Script" category is disabled.' return @@ -129,7 +129,7 @@ class ScriptRegistry : EntryRegistry { $entry.UserData = @{ ScriptBlock = $this.scriptFileCallback - ArgumentList = $filePath + ArgumentList = $filePath, $argumentList } if ($entryGroup) { diff --git a/module/PowerShellRun/Public/Add-PSRunScriptFile.ps1 b/module/PowerShellRun/Public/Add-PSRunScriptFile.ps1 index 6d702a1..1051d89 100644 --- a/module/PowerShellRun/Public/Add-PSRunScriptFile.ps1 +++ b/module/PowerShellRun/Public/Add-PSRunScriptFile.ps1 @@ -8,6 +8,9 @@ Adds a script file as an entry that can be invoked on selection. The entry belon .PARAMETER Path The filepath of the script file. +.PARAMETER ArgumentList +The arguments that are passed to the script file. + .PARAMETER Icon The icon string. @@ -41,6 +44,9 @@ function Add-PSRunScriptFile { [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] [String]$Path, + [Parameter(ValueFromPipelineByPropertyName = $true)] + [Object[]]$ArgumentList, + [Parameter(ValueFromPipelineByPropertyName = $true)] [String]$Icon, @@ -59,6 +65,6 @@ function Add-PSRunScriptFile { process { $registry = $script:globalStore.GetRegistry('ScriptRegistry') - $registry.AddScriptFile($Path, $Icon, $Name, $Description, $Preview, $EntryGroup) + $registry.AddScriptFile($Path, $ArgumentList, $Icon, $Name, $Description, $Preview, $EntryGroup) } }