🪲 [Fix]: Add -PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support#93
Merged
Conversation
…t functions for pipeline support
-PassThru parameter to Set-Context and Set-ContextVault functions for pipeline support
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a -PassThru switch to both Set-ContextVault and Set-Context so that these cmdlets can emit their resulting objects down the pipeline.
- Introduced the
-PassThruparameter in both functions and wired it through fromSet-ContexttoSet-ContextVault. - Updated tests in
ContextVaults.Tests.ps1to invoke-PassThruand validate returned vault objects.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/functions/public/Vault/Set-ContextVault.ps1 | Added -PassThru switch and conditional object output in process |
| src/functions/public/Set-Context.ps1 | Added -PassThru switch, passed it to Set-ContextVault and conditionally emitted context |
| tests/ContextVaults.Tests.ps1 | Updated test cases to include -PassThru and assert returned types |
Comments suppressed due to low confidence (4)
tests/ContextVaults.Tests.ps1:57
- The pipeline input test only asserts that
Namecontains 'test-pipeline1'; consider also checking for 'test-pipeline2' and verifying thatPathis not null or empty for each returned object to fully validate the output.
$results = 'test-pipeline1', 'test-pipeline2' | Set-ContextVault -PassThru
src/functions/public/Vault/Set-ContextVault.ps1:32
- [nitpick] The new
-PassThruparameter isn't documented in the function's comment-based help; consider adding a.PARAMETER PassThruentry and an example usage so users know how to emit the vault object.
[switch] $PassThru
src/functions/public/Set-Context.ps1:74
- [nitpick] The function help block should be updated to include a description for the new
-PassThruswitch and an example of using it to return the context object in the pipeline.
[switch] $PassThru
src/functions/public/Set-Context.ps1:126
- There are no existing tests for
Set-Context -PassThru; consider adding a test that verifies the context object is returned when-PassThruis specified.
if ($PassThru) {
…e operations test
…-Context, and Reset-ContextVault functions for pipeline support
|
Module Context - 8.0.2 published to the PowerShell Gallery. |
|
GitHub release for Context v8.0.2 has been created. |
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.
Description
This pull request introduces a new
-PassThruparameter to theSet-ContextandSet-ContextVaultfunctions, allowing users to pass objects through the pipeline. Corresponding updates have been made to the logic and tests to support this functionality.Enhancements to
Set-ContextandSet-ContextVaultfunctions:-PassThruparameter toSet-Context: This optional parameter enables the function to return the context object through the pipeline if specified. (src/functions/public/Set-Context.ps1, [1] [2]Set-ContextVaultcalls withinSet-Context: Updated to include the-PassThruparameter when invokingSet-ContextVault, ensuring consistent behavior. (src/functions/public/Set-Context.ps1, src/functions/public/Set-Context.ps1L79-R83)Enhancements to
Set-ContextVaultfunction:-PassThruparameter toSet-ContextVault: This optional parameter allows the function to return the created or updated vault object through the pipeline if specified. (src/functions/public/Vault/Set-ContextVault.ps1, [1] [2]Test updates:
Set-ContextVault: Modified test cases to include the-PassThruparameter, ensuring the returned objects meet the expected type and content. (tests/ContextVaults.Tests.ps1, tests/ContextVaults.Tests.ps1L41-R57)Type of change
Checklist