From c4777a2c4a1b0424f754071360792330afce75ec Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 25 Nov 2024 20:25:04 +0100 Subject: [PATCH] Disconnect with input + silent --- .../public/Auth/Disconnect-GitHubAccount.ps1 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 index 57cbf2a0b..e47424a56 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" }