Skip to content

Commit

Permalink
Disconnect with input + silent
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Nov 25, 2024
1 parent 3d90cb5 commit c4777a2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/functions/public/Auth/Disconnect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit c4777a2

Please sign in to comment.