diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 index 57cbf2a0..e47424a5 100644 --- a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 @@ -36,18 +36,25 @@ # The context to log out of. [Parameter()] [Alias('Name')] - [string] $Context = (Get-GitHubConfig -Name 'DefaultContext') + [string] $Context = (Get-GitHubConfig -Name 'DefaultContext'), + + # Silently disconnects from GitHub. + [switch] $Silent ) $commandName = $MyInvocation.MyCommand.Name Write-Verbose "[$commandName] - Start" - $Context = Get-GitHubConfig -Name 'DefaultContext' Remove-GitHubContext -Context $Context - Remove-GitHubConfig -Name 'DefaultContext' - - Write-Host '✓ ' -ForegroundColor Green -NoNewline - Write-Host "Logged out of GitHub! [$Context]" + $isDefaultContext = $Context -eq (Get-GitHubConfig -Name 'DefaultContext') + if ($isDefaultContext) { + Remove-GitHubConfig -Name 'DefaultContext' + } + + if (-not $Silent) { + Write-Host '✓ ' -ForegroundColor Green -NoNewline + Write-Host "Logged out of GitHub! [$Context]" + } Write-Verbose "[$commandName] - End" }