Support PleaseWork Task Arguments - #49
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the PleaseWork PowerShell task runner to support passing task-specific named arguments by exposing each task’s param() block as dynamic parameters on Invoke-PleaseWork (aka please). It also refactors argument completion into a dedicated exported function and improves failure-output capture during task execution.
Changes:
- Add dynamic parameter binding from TaskFile task
param()blocks (including aliases/validation) and forward bound args only to the requested task. - Introduce
Complete-PleaseWorkTaskas the argument completer implementation (and export it). - Update execution/output behavior and docs (e.g.,
$ChangedFilesnow absolute; output before failure is preserved).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/PleaseWork/Tests/Public/Invoke-PleaseWork.tests.ps1 | Adds coverage for task param binding and completion; updates expectations for output + $ChangedFiles shape. |
| src/modules/PleaseWork/Tests/Private/PleaseWork.Module.tests.ps1 | Updates export expectations to include Complete-PleaseWorkTask. |
| src/modules/PleaseWork/Tests/Private/Invoke-PleaseWorkTask.tests.ps1 | Adds coverage for isolated named-argument binding in task module scope. |
| src/modules/PleaseWork/taskfile.ps1 | Adjusts module tasks: adds dependency ordering, changes lint behavior, adds install task. |
| src/modules/PleaseWork/src/Public/Invoke-PleaseWork.ps1 | Implements dynamic task parameters and forwards bound task args only to the requested task. |
| src/modules/PleaseWork/src/Public/Complete-PleaseWorkTask.ps1 | New exported completer function for task name completion (including native help). |
| src/modules/PleaseWork/src/Private/Resolve-ParamBlock.ps1 | Rebuilds attributes from AST constants to support alias/validation metadata in dynamic parameters. |
| src/modules/PleaseWork/src/Private/Invoke-PleaseWorkTask.ps1 | Changes invocation wrapper to preserve output before failure and support named splatting. |
| src/modules/PleaseWork/src/Private/Get-TaskDeclaration.ps1 | Captures task ParameterAsts for dynamic param generation without executing the TaskFile. |
| src/modules/PleaseWork/README.md | Documents task parameter support and clarifies $ChangedFiles/$LASTEXITCODE behavior. |
| src/modules/PleaseWork/PleaseWork.psd1 | Updates exported functions list (adds Complete-PleaseWorkTask). |
| src/modules/GrabBag/Public/Resolve-ParamBlock.ps1 | Adds namespace imports (supporting updated typing/style). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+49
to
+55
| $TaskFilePath = Resolve-TaskFilePath -Path $BoundTaskFile | ||
| $TaskDeclarations = @(Get-TaskFileDeclaration -Path $TaskFilePath) | ||
| $SelectedTaskName = if ([string]::IsNullOrEmpty($BoundTaskName)) { | ||
| $TaskDeclarations[0].Name | ||
| } else { | ||
| $BoundTaskName | ||
| } |
Comment on lines
24
to
+29
| [Parameter()] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string] $TaskFile, | ||
|
|
||
| [Parameter(ParameterSetName='Run')] | ||
| [switch] $PassThru, | ||
|
|
||
| [Parameter(ParameterSetName='Run',ValueFromRemainingArguments)] | ||
| [object[]] $RemainingArguments | ||
| [switch] $PassThru |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For the record, it was my idea to use
Resolve-ParamBlockto populatedynamicparamwith the runtime parameters from the scriptblock so while I may have had copilot do the implementation, not gonna let anyone say I didn't contribute to this. Personally, I think it was a rather clever idea even if I'm not clever enough to take it across the finish line myself :/TODO: There seems to be an issue running lint/test tasks within VSCode. Unclear why but can't merge this just yet.