Skip to content

Commit

Permalink
Adding -Force switch to ConfirmImpact=High functions (#226)
Browse files Browse the repository at this point in the history
Adding -Force switch to ConfirmImpact=High functions and updated affected tests/documentation

Fixes #218
  • Loading branch information
giuseppecampanelli authored Jun 10, 2020
1 parent 66dba36 commit 3c642d2
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 13 deletions.
19 changes: 17 additions & 2 deletions GitHubAssignees.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ function Remove-GithubAssignee
.PARAMETER Assignee
Usernames of assignees to remove from an issue. NOTE: Only users with push access can remove assignees from an issue. Assignees are silently ignored otherwise.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -327,12 +330,17 @@ function Remove-GithubAssignee
.EXAMPLE
Remove-GithubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignee $assignees
Lists the available assignees for issues from the Microsoft\PowerShellForGitHub project.
Removes the available assignees for issues from the Microsoft\PowerShellForGitHub project.
.EXAMPLE
Remove-GithubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignee $assignees -Confirm:$false
Lists the available assignees for issues from the Microsoft\PowerShellForGitHub project. Will not prompt for confirmation, as -Confirm:$false was specified.
Removes the available assignees for issues from the Microsoft\PowerShellForGitHub project. Will not prompt for confirmation, as -Confirm:$false was specified.
.EXAMPLE
Remove-GithubAssignee -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Assignee $assignees -Force
Removes the available assignees for issues from the Microsoft\PowerShellForGitHub project. Will not prompt for confirmation, as -Force was specified.
#>
[CmdletBinding(
SupportsShouldProcess,
Expand All @@ -357,6 +365,8 @@ function Remove-GithubAssignee
[Parameter(Mandatory)]
[string[]] $Assignee,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -379,6 +389,11 @@ function Remove-GithubAssignee
'assignees' = $Assignee
}

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Assignee -join ', ', "Remove assignee(s)"))
{
$params = @{
Expand Down
15 changes: 15 additions & 0 deletions GitHubComments.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ function Remove-GitHubComment
.PARAMETER CommentID
The id of the comment to delete.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -456,6 +459,11 @@ function Remove-GitHubComment
.EXAMPLE
Remove-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -CommentID 1 -Confirm:$false
Deletes a Github comment from the Microsoft\PowerShellForGitHub project without prompting confirmation.
.EXAMPLE
Remove-GitHubComment -OwnerName Microsoft -RepositoryName PowerShellForGitHub -CommentID 1 -Force
Deletes a Github comment from the Microsoft\PowerShellForGitHub project without prompting confirmation.
#>
[CmdletBinding(
Expand All @@ -479,6 +487,8 @@ function Remove-GitHubComment
[Parameter(Mandatory)]
[string] $CommentID,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -496,6 +506,11 @@ function Remove-GitHubComment
'CommentID' = (Get-PiiSafeString -PlainText $CommentID)
}

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($CommentID, "Remove comment"))
{
$params = @{
Expand Down
30 changes: 30 additions & 0 deletions GitHubLabels.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ function Remove-GitHubLabel
Name of the label to be deleted.
Emoji and codes are supported. For more information, see here: https://www.webpagefx.com/tools/emoji-cheat-sheet/
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -321,6 +324,11 @@ function Remove-GitHubLabel
Remove-GitHubLabel -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Name TestLabel -Confirm:$false
Removes the label called "TestLabel" from the PowerShellForGitHub project. Will not prompt for confirmation, as -Confirm:$false was specified.
.EXAMPLE
Remove-GitHubLabel -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Name TestLabel -Force
Removes the label called "TestLabel" from the PowerShellForGitHub project. Will not prompt for confirmation, as -Force was specified.
#>
[CmdletBinding(
SupportsShouldProcess,
Expand All @@ -345,6 +353,8 @@ function Remove-GitHubLabel
[Alias('LabelName')]
[string] $Name,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -361,6 +371,11 @@ function Remove-GitHubLabel
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
}

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Name, "Remove label"))
{
$params = @{
Expand Down Expand Up @@ -859,6 +874,9 @@ function Remove-GitHubIssueLabel
Name of the label to be deleted. If not provided, will delete all labels on the issue.
Emoji and codes are supported. For more information, see here: https://www.webpagefx.com/tools/emoji-cheat-sheet/
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -878,6 +896,11 @@ function Remove-GitHubIssueLabel
Remove-GitHubIssueLabel -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Name TestLabel -Issue 1 -Confirm:$false
Removes the label called "TestLabel" from issue 1 in the PowerShellForGitHub project. Will not prompt for confirmation, as -Confirm:$false was specified.
.EXAMPLE
Remove-GitHubIssueLabel -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Name TestLabel -Issue 1 -Force
Removes the label called "TestLabel" from issue 1 in the PowerShellForGitHub project. Will not prompt for confirmation, as -Force was specified.
#>
[CmdletBinding(
SupportsShouldProcess,
Expand All @@ -901,6 +924,8 @@ function Remove-GitHubIssueLabel
[Alias('LabelName')]
[string] $Name,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand Down Expand Up @@ -928,6 +953,11 @@ function Remove-GitHubIssueLabel
$description = "Deleting all labels from issue $Issue in $RepositoryName"
}

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Name, "Remove label"))
{
$params = @{
Expand Down
15 changes: 15 additions & 0 deletions GitHubMilestones.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ function Remove-GitHubMilestone
.PARAMETER Milestone
The number of a specific milestone to delete.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -505,6 +508,11 @@ function Remove-GitHubMilestone
Remove-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Milestone 1 -Confirm:$false
Deletes a Github milestone from the Microsoft\PowerShellForGitHub project. Will not prompt for confirmation, as -Confirm:$false was specified.
.EXAMPLE
Remove-GitHubMilestone -OwnerName Microsoft -RepositoryName PowerShellForGitHub -Milestone 1 -Force
Deletes a Github milestone from the Microsoft\PowerShellForGitHub project. Will not prompt for confirmation, as -Force was specified.
#>
[CmdletBinding(
SupportsShouldProcess,
Expand All @@ -526,6 +534,8 @@ function Remove-GitHubMilestone
[Parameter(Mandatory, ParameterSetName='Elements')]
[string] $Milestone,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -543,6 +553,11 @@ function Remove-GitHubMilestone
'Milestone' = (Get-PiiSafeString -PlainText $Milestone)
}

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Milestone, "Remove milestone"))
{
$params = @{
Expand Down
15 changes: 15 additions & 0 deletions GitHubProjectCards.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ function Remove-GitHubProjectCard
.PARAMETER Card
ID of the card to remove.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -364,6 +367,11 @@ function Remove-GitHubProjectCard
.EXAMPLE
Remove-GitHubProjectCard -Card 999999 -Confirm:$False
Remove project card with ID 999999 without prompting for confirmation.
.EXAMPLE
Remove-GitHubProjectCard -Card 999999 -Force
Remove project card with ID 999999 without prompting for confirmation.
#>
[CmdletBinding(
Expand All @@ -375,6 +383,8 @@ function Remove-GitHubProjectCard
[Parameter(Mandatory)]
[int64] $Card,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -387,6 +397,11 @@ function Remove-GitHubProjectCard
$uriFragment = "/projects/columns/cards/$Card"
$description = "Deleting card $Card"

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Card, "Remove card"))
{
$params = @{
Expand Down
15 changes: 15 additions & 0 deletions GitHubProjectColumns.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ function Remove-GitHubProjectColumn
.PARAMETER Column
ID of the column to remove.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -260,6 +263,11 @@ function Remove-GitHubProjectColumn
.EXAMPLE
Remove-GitHubProjectColumn -Column 999999 -Confirm:$False
Removes the project column with ID 999999 without prompting for confirmation.
.EXAMPLE
Remove-GitHubProjectColumn -Column 999999 -Force
Removes the project column with ID 999999 without prompting for confirmation.
#>
[CmdletBinding(
Expand All @@ -271,6 +279,8 @@ function Remove-GitHubProjectColumn
[Parameter(Mandatory)]
[int64] $Column,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -283,6 +293,11 @@ function Remove-GitHubProjectColumn
$uriFragment = "/projects/columns/$Column"
$description = "Deleting column $Column"

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($Column, "Remove column"))
{
$params = @{
Expand Down
15 changes: 15 additions & 0 deletions GitHubProjects.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ function Remove-GitHubProject
.PARAMETER Project
ID of the project to remove.
.PARAMETER Force
If this switch is specified, you will not be prompted for confirmation of command execution.
.PARAMETER AccessToken
If provided, this will be used as the AccessToken for authentication with the
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
Expand All @@ -470,6 +473,11 @@ function Remove-GitHubProject
Remove project with ID '4387531' without prompting for confirmation.
.EXAMPLE
Remove-GitHubProject -Project 4387531 -Force
Remove project with ID '4387531' without prompting for confirmation.
.EXAMPLE
$project = Get-GitHubProject -OwnerName Microsoft -RepositoryName PowerShellForGitHub | Where-Object Name -eq 'TestProject'
Remove-GitHubProject -Project $project.id
Expand All @@ -486,6 +494,8 @@ function Remove-GitHubProject
[Parameter(Mandatory)]
[int64] $Project,

[switch] $Force,

[string] $AccessToken,

[switch] $NoStatus
Expand All @@ -498,6 +508,11 @@ function Remove-GitHubProject
$uriFragment = "projects/$Project"
$description = "Deleting project $Project"

if ($Force -and (-not $Confirm))
{
$ConfirmPreference = 'None'
}

if ($PSCmdlet.ShouldProcess($project, "Remove project"))
{
$params = @{
Expand Down
Loading

0 comments on commit 3c642d2

Please sign in to comment.