-
Notifications
You must be signed in to change notification settings - Fork 191
PowerShellForGitHub: Suggested WhatIf/Confirm Processing Improvements #225
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
Comments
Awesome write-up, @X-Guardian. The only place in the module with a call to Beyond that, I'm ok with you proposal. My main request here would still to perform the check similar to how it's done in Marking this as |
Hi @HowardWolosky, yes you are right about |
I've just been looking through the functions and most if not all of the non-state changing functions ( What do you think about also removing |
I think your instinct here is probably right. I checked a number of the built-in Go for it. |
Issue Details
Since PR #213, the
ShouldProcess
(WhatIf/Confirm) processing in the module is better, but it still could be improved.The
PowerShellForGuthub
functions are designed to be consumed by other scripts/functions,so the norm in this case is for each function to only ever output a single
ShouldProcess
prompt.Currently, most functions output at least two prompts, for example:
The
WhatIf
for the 'Output to File' should not be shown, and the secondWhatIf
has a non-useful operation and target. It should be:What if: Performing the operation "Create Repository" on target "test"
.Also, if a function is given an invalid set of parameters, for example:
The
WhatIf
for the 'Output to File' should not be shown.Suggested solution to the issue
$PSCmdlet.ShouldProcess
check out ofInvoke-GHRestMethod
and add it to the calling functions with the correct operation and target (as has been done for theConfirmHighImpact
PR Add confirmation prompts and examples for Remove- functions #174).Write-InvocationLog -Invocation $MyInvocation
line in each resource function to within the$PSCmdlet.ShouldProcess
condition block. This will prevent the log being updated ifShouldProcess
is $false.-WhatIf:$false
to theOut-File
Cmdlet call in theWrite-Log
function in theHelpers
module. This will prevent theWrite-Log
function displayingWhatIf
.This would also have the additional benefit of being able to remove the
SuppressMessageAttribute
PSShouldProcess
decorator from all the functions, as theShouldProcess
logic will now be happening within the function.Requested Assignment
Operating System
PowerShell Version
Module Version
Running: 0.14.0
Installed: 0.14.0
The text was updated successfully, but these errors were encountered: