Repository navigation
Get XKCDExplanation
Gets the explanation of a comic from the explain xkcd wiki: https://www.explainxkcd.com/.
Get-XKCDExplanation [-Open] [-Explanation] [-Transcript] [-Discussion] [-Full] [-Show] [-HighQuality]
[-ApiUrl <String>] [[-Number] <Int32[]>] [-Force] [-ProgressAction <ActionPreference>] [<CommonParameters>]
Get-XKCDExplanation [-Random] [-Minimum <Int32>] [-Maximum <Int32>] [-Open] [-Explanation] [-Transcript]
[-Discussion] [-Full] [-Show] [-HighQuality] [-ApiUrl <String>] [-Force] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Get-XKCDExplanation [-Newest <Int32>] [-Open] [-Explanation] [-Transcript] [-Discussion] [-Full] [-Show]
[-HighQuality] [-ApiUrl <String>] [-Force] [-ProgressAction <ActionPreference>] [<CommonParameters>]
The Get-XKCDExplanation cmdlet uses the explain xkcd wiki's MediaWiki API to retrieve a comic's "Explanation" section, and optionally its "Transcript" section and reader "Discussion" (from its explain xkcd talk page), returning them as plain text, with the wiki markup used by the site stripped out for readability.
By default, only the Explanation is retrieved. Use -Transcript and/or -Discussion to also retrieve those sections on the returned object, or -Full to always retrieve all three. Sections that aren't requested are never fetched from the API (saving a request each) and are omitted from the returned object entirely, rather than being included empty.
With -Show (or on Show-XKCDExplanation), -Explanation, -Transcript, and -Discussion each display just that one section -- e.g. -Show -Transcript on its own displays just the transcript, not the explanation. Combine them to display more than one, or use -Full to always display all three. Each displayed section is given its own heading. These same switches determine what's fetched as well as what's displayed, so -Show never retrieves a section it isn't about to show.
With -Show, -Explanation, -Transcript, and -Discussion (without -Full) display text sections only, without fetching or showing the comic image -- the title and a link to the explanation are still shown. Use -Full with -Show to always display the comic image alongside every section.
By default, Get-XKCDExplanation returns the explanation of the latest available comic. Use -Random to get a random comic instead (optionally within a -Minimum/-Maximum range), or -Newest to get the specified number of most recent comics. Use the -Number parameter (aliased as -Num) to specify one or more specific comics to return.
Get-XKCDExplanation
This command gets the explanation of the latest XKCD comic.
Get-XKCDExplanation 2000
This command returns the explanation of the 2000th XKCD comic.
Get-XKCD -Random | Get-XKCDExplanation
This command gets a random comic and then returns its explanation.
Get-XKCDExplanation -Random -Minimum 100 -Maximum 150
This command returns the explanation of a random comic numbered between 100 and 150.
Get-XKCDExplanation -Newest 5
This command returns the explanation of the latest 5 comics.
(Get-XKCDExplanation 2000 -Transcript).Transcript
This command returns just the transcript of comic number 2000. -Transcript is required to retrieve it -- by default only the Explanation is fetched and returned.
Get-XKCDExplanation -Number 1 -Full -Show
This command displays the title, image, explanation, transcript, and discussion of comic number 1 directly in the console, each under its own heading (image display requires your terminal to support the Sixel, Kitty, or iTerm2 inline image protocol). Unlike other parameter combinations, -Show does not return the explanation object.
Get-XKCDExplanation -Number 1 -Explanation -Show
This command displays just the explanation of comic number 1 as text, along with its title and a link, without fetching or displaying the comic image.
Get-XKCDExplanation -Open
This command returns the explanation of the latest comic and opens it in your default web browser.
Gets the explanation of a random comic.
Type: SwitchParameter
Parameter Sets: Random
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseUse with -Random to define a lower bound range within which to return a comic.
Type: Int32
Parameter Sets: Random
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: FalseUse with -Random to define an upper bound range within which to return a comic. -Maximum is the latest comic number by default.
Type: Int32
Parameter Sets: Random
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseGets the explanation of the specified number of the most recent comics.
Type: Int32
Parameter Sets: Newest
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseOpens the comic/s in your default web browser.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseRetrieves, and with -Show displays, the comic's "Explanation" section. The Explanation is always retrieved regardless of this switch -- it only affects what -Show displays, where combining it with -Transcript and/or -Discussion displays more than one section. Defaults to the value saved with Set-XKCDDefault -Explanation, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'Explanation' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseRetrieves, and with -Show displays, the comic's "Transcript" section. Without this switch (or -Full), the Transcript is not fetched and its property is omitted from the returned object entirely. Combine with -Explanation and/or -Discussion to display more than one section with -Show. Defaults to the value saved with Set-XKCDDefault -Transcript, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'Transcript' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseRetrieves, and with -Show displays, the comic's reader "Discussion", from its explain xkcd talk page. Without this switch (or -Full), the Discussion is not fetched and its property is omitted from the returned object entirely. Combine with -Explanation and/or -Transcript to display more than one section with -Show. Defaults to the value saved with Set-XKCDDefault -Discussion, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'Discussion' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseRetrieves, and with -Show displays, all of the explanation, transcript, and discussion sections. Defaults to the value saved with Set-XKCDDefault -Full, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'Full' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseDisplays the comic's title, image, and retrieved sections in the console instead of returning the explanation object. Image display requires your terminal to support the Sixel, Kitty, or iTerm2 inline image graphics protocol.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseUse with -Show to display the higher resolution (_2x) version of the image, where available. Comics that do not have a higher resolution version are displayed at the standard quality instead. Defaults to the value saved with Set-XKCDDefault -HighQuality, if any.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Get-XKCDDefaultValue -Name 'HighQuality' -Value $false)
Accept pipeline input: False
Accept wildcard characters: FalseThe base URL of the explain xkcd wiki's MediaWiki API.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Https://www.explainxkcd.com/wiki/api.php
Accept pipeline input: False
Accept wildcard characters: FalseGets the explanation of the specified comics. Accepts array input. By default the latest comic is used.
Type: Int32[]
Parameter Sets: Specific
Aliases: Num
Required: False
Position: 1
Default value: $Maximum
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: FalseBypass the confirmation check if you try to open more than 9 comics in your browser.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis 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).
https://github.com/markwragg/Powershell-XKCD/wiki/Get-XKCDExplanation