-
Notifications
You must be signed in to change notification settings - Fork 133
Add RFC: Granular Applications of ConfirmImpact #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@vexx32 I know this is an old one, but would you mind defining the optional parameter that you're hoping to add, and how it might work in an example like the 50 machines getting Invoke-Command run against them? Or if you don't feel this is important anymore, you can update it to Withdrawn or just close it. |
@joeyaiello added some more information and explanation around the method overloads, implementation example, and motivation. Let me know if y'all need anything more 💖 |
Thank you, that's a lot more helpful. We all had an aha moment on the @PowerShell/powershell-committee as soon as we saw the overload. We're still having trouble coming up with a realistic scenario for when this would be useful. I put one on the table--checking to see if a file is system-protected on Windows as a high severity thing--but the list stopped there. Did you have more specific conditions in mind than the admittedly PoC example you showed? Furthermore, it will be difficult for new modules to take advantage of these overloads because they won't work downlevel. For at least a couple years, the only modules that could generally take a dependency on this is stuff we ship as part of PowerShell. |
In my opinion, pretty much any scenario that currently is utilising a I think it's less than ideal to perpetuate a pattern that demands a parameter that has no common definition / isn't a common parameter supplied from Careless authors may use And yes, as with any change of this nature, it is only available after the version it's implemented in. While this is to some extent a decent argument, it's also universally true for pretty much anything we talk about adding to PowerShell. If that's one of the main limiting factors in any decision, I can't really weigh it particularly heavily -- if we preclude progress based mainly on that, we'll never get anywhere. 🙂 A possible alternative option would be to create a module that handles this instead and expose it as cmdlets, e.g., IMO the API could use some improvement going forward in any case, which is why I proposed the improvement to the API itself first 🙂 |
This would be nice to have but do we really ready to review most of popular cmdlets/modules and make many breaking changes to implement the RFC? Without this the RFC will be die RFC. |
@iSazonov at least in the beginning no breaking changes are necessary. Something like this would be perfectly fine: if (Force.IsPresent || ShouldProcess(target, actionString, ConfirmImpact.High))
{
// Replaces the functionality of the old ShouldContinue() pattern.
} |
@vexx32: we had a discussion with the @PowerShell/powershell-committee on this one today. We agree with the issues that you raised with One proposal we floated to solve this problem differently is to use For more info, see this example: function set-thing {
[CmdletBinding(SupportsShouldProcess=$true)]
param ( [switch]$noask )
process {
if ( $noask -or $PSCmdlet.ShouldContinue("foo","bar")) {
write-host "DO IT NOW"
} else {
write-host "Don't Do It"
}
}
} Unfortunately, this precludes the ability to easily bypass all confirmation prompts within an automation scenario. So, one alternate proposal may be to make a breaking change to If none of this scans for you, it'd still be really great to see an experiment of this within its own module on the Gallery so that we can see if others have interest in this scenario. If you're interested in any of these additional proposals and/or you implement said module and believe it has wide-reaching utility, then you should open a new issue to discuss this in more depth over at PowerShell/PowerShell. For the time being, given the lack of interest in this particular RFC, we're going to close it. |
Fair enough! I think the issue of overloading In my mind, Were it up to me, I would probably just remove ShouldContinue() from any documentation that currently recommends its use and replace it with ShouldProcess(), or perhaps relegate it to a footnote, being careful to note its incompatibility with automation scenarios and likely limited use case as a result. It's an API that maybe in some cases is necessary, but I think on the whole it tends to be more trouble than it's worth to use it in a way that doesn't make the tool you're writing non-functional in an automation context. Perhaps some notes to that effect in its documentation would go a good way to helping folks pick the right options for what they intend their tools to be used for. |
No description provided.