-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 66-get-steamfriendlist-should-return-a-pso…
…bject
- Loading branch information
Showing
4 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
function Disconnect-SteamAPI { | ||
<# | ||
.SYNOPSIS | ||
Disconnects from the Steam API by removing the stored API key. | ||
.DESCRIPTION | ||
The Disconnect-SteamAPI cmdlet removes the stored Steam API key from the system. This effectively disconnects the current session from the Steam API. | ||
.PARAMETER Force | ||
When the Force switch is used, the cmdlet will skip the confirmation prompt and directly remove the API key. | ||
.EXAMPLE | ||
Disconnect-SteamAPI -Force | ||
This command will remove the stored Steam API key without asking for confirmation. | ||
.INPUTS | ||
None. You cannot pipe objects to Disconnect-SteamAPI. | ||
.OUTPUTS | ||
None. Nothing is returned when calling Disconnect-SteamAPI. | ||
.NOTES | ||
Author: Frederik Hjorslev Nylander | ||
.LINK | ||
https://hjorslev.github.io/SteamPS/Disconnect-SteamAPI.html | ||
#> | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $false, | ||
HelpMessage = 'Skip the confirmation prompt.')][switch]$Force | ||
) | ||
|
||
begin { | ||
Write-Verbose -Message "[BEGIN ] Starting: $($MyInvocation.MyCommand)" | ||
$SteamAPIKey = "$env:AppData\SteamPS\SteamPSKey.json" | ||
} | ||
|
||
process { | ||
if ($Force -or $PSCmdlet.ShouldContinue($SteamAPIKey, 'Do you want to continue removing the API key?')) { | ||
if (Test-Path -Path $SteamAPIKey) { | ||
Remove-Item -Path $SteamAPIKey -Force | ||
Write-Verbose -Message "$SteamAPIKey were deleted." | ||
} else { | ||
$Exception = [Exception]::new("Steam Web API configuration file not found in '$env:AppData\SteamPS\SteamPSKey.json'.") | ||
$ErrorRecord = [System.Management.Automation.ErrorRecord]::new( | ||
$Exception, | ||
'SteamAPIKeyNotFound', | ||
[System.Management.Automation.ErrorCategory]::ObjectNotFound, | ||
$SteamPSKey | ||
) | ||
$PSCmdlet.ThrowTerminatingError($ErrorRecord) | ||
} | ||
} | ||
} | ||
|
||
end { | ||
Write-Verbose -Message "[END ] Ending: $($MyInvocation.MyCommand)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Describe 'Disconnect-SteamAPI Tests' { | ||
Context 'When Force is specified and API key is found' { | ||
BeforeAll { | ||
Mock -CommandName Test-Path -ModuleName SteamPS -MockWith { return $true } -Verifiable -ParameterFilter { $Path -eq "$env:AppData\SteamPS\SteamPSKey.json" } | ||
Mock -CommandName Remove-Item -ModuleName SteamPS -MockWith {} -Verifiable -ParameterFilter { $Path -eq "$env:AppData\SteamPS\SteamPSKey.json" } | ||
} | ||
It 'Deletes the Steam API key file' { | ||
Disconnect-SteamAPI -Force | Should -InvokeVerifiable | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
external help file: SteamPS-help.xml | ||
Module Name: SteamPS | ||
online version: https://hjorslev.github.io/SteamPS/Disconnect-SteamAPI.html | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Disconnect-SteamAPI | ||
|
||
## SYNOPSIS | ||
Disconnects from the Steam API by removing the stored API key. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Disconnect-SteamAPI [-Force] [-ProgressAction <ActionPreference>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
The Disconnect-SteamAPI cmdlet removes the stored Steam API key from the system. | ||
This effectively disconnects the current session from the Steam API. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
Disconnect-SteamAPI -Force | ||
``` | ||
|
||
This command will remove the stored Steam API key without asking for confirmation. | ||
|
||
## PARAMETERS | ||
|
||
### -Force | ||
When the Force switch is used, the cmdlet will skip the confirmation prompt and directly remove the API key. | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -ProgressAction | ||
{{ Fill ProgressAction Description }} | ||
```yaml | ||
Type: ActionPreference | ||
Parameter Sets: (All) | ||
Aliases: proga | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
### None. You cannot pipe objects to Disconnect-SteamAPI. | ||
## OUTPUTS | ||
### None. Nothing is returned when calling Disconnect-SteamAPI. | ||
## NOTES | ||
Author: Frederik Hjorslev Nylander | ||
## RELATED LINKS | ||
[https://hjorslev.github.io/SteamPS/Disconnect-SteamAPI.html](https://hjorslev.github.io/SteamPS/Disconnect-SteamAPI.html) | ||