GithubHelp home page GithubHelp logo

markwragg / powershell-xkcd Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 2.0 1.81 MB

A PowerShell module for accessing the XKCD API to get the details of and (optionally) download the excellent webcomics @ http://xkcd.com

PowerShell 100.00%
xkcd powershell xkcd-api webcomics

powershell-xkcd's Introduction

Powershell-XKCD

Build Status Test Coverage

A PowerShell function for accessing the XKCD API to get the details of and (optionally) download the excellent webcomics @ http://xkcd.com.

XKCD

XKCD is a webcomic by Randall Munroe. Please respect the license of his work as described here: http://xkcd.com/license.html.

Requirements

Installation

This module is published in the PowerShell Gallery as XKCD so if you have PowerShell 5 or the Package Management modules, it can be installed by entering the following in a PowerShell window:

Install-Module -Name XKCD

Usage Examples

  1. Get-XKCD

By default (and with no specified parameters) the function will return a PowerShell object with the details of the latest webcomic. For example:

month      : 1
num        : 1786
link       : 
year       : 2017
news       : 
safe_title : Trash
transcript : 
alt        : Plus, time's all weird in there, so most of it probably broke down and decomposed hundreds of years ago. Which reminds me, I've been meaning to get in touch 
             with Yucca Mountain to see if they're interested in a partnership.
img        : http://imgs.xkcd.com/comics/trash.png
title      : Trash
day        : 16
  1. Get-XKCD 1 or Get-XKCD -num 1

Specify the number of specifc comic/s you want to access via the -num parameter (this is a positional parameter so it doesn't need to be explicitly used).

  1. Get-XKCD -Random or Get-XKCD -Random -Min 1 -Max 10

Use the -Random switch to get a Random comic. Optionally specify Min and Max if you want to restrict the randomisation to a specific range of comic numbers.

  1. Get-XKCD -Newest 5

Use the -Newest switch to get a specified number of the newest comics. Note this cannot be used with -Random (and vice versa).

  1. Get-XKCD 1,5,10 or 10..20 | Get-XKCD

The number paramater accepts array input and pipeline input, so you can use either to return a specific selection in one hit.

  1. Get-XKCD -Download or Get-XKCD 1337 -Download -Path C:\XKCD

Use the -Download switch to download the image/s of the returned comics. Optionally specify a path to download to, by default it uses the current directory. Note you can use -Download and -Path with any of the other parameters.

  1. 1..10 | % { Get-XKCD -Random -min 1 -max 100 | select num,img } | FT -AutoSize

This calls Get-XKCD 10 times in a foreach loop, returning the number and image URL of 10 random comics from the first 100 comics and presenting them as an autosized table.

Contributions

Code contrbutions and pull requests are welcomed. Please note this function is also intended to represent a (hopefully) best practice example of a cmdlet which respects the pipeline and an example of how to utilise Parameter Sets to provide a dynamic set of functionality.

powershell-xkcd's People

Contributors

markwragg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

powershell-xkcd's Issues

No modules published

Script reported no modules were configured to publish in appveyor.yml but the setting is *.

Code coverage

Look in to checking/reporting code coverage (in AppVeyor push to messages tab?)

Find-XKCD function

Build an offline cache of all comic data which we can then search to find specific comics based on keyword, date etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.