xkcd-go

Golang tool to read latest, random, or a specific xkcd comic (and download it too).
git clone http://git.hanabi.in/repos/xkcd-go.git
Log | Files | Refs | README | LICENSE

main.go (622B)


      1 package main
      2 
      3 import (
      4 	"fmt"
      5 	"log"
      6 	"os"
      7 
      8 	xkcd "git.hanabi.in/dev/xkcd/src/xkcd"
      9 )
     10 
     11 func main() {
     12 	option, num, err := xkcd.GetOption(os.Args)
     13 	if err != nil {
     14 		log.Fatal(err)
     15 	}
     16 	var msg string
     17 	if option == "help" {
     18 		msg = xkcd.ShowHelp()
     19 	} else if option == "random" {
     20 		msg = xkcd.FetchRandomXKCD()
     21 	} else if option == "latest" {
     22 		msg = xkcd.FetchLatestXKCD()
     23 	} else if option == "get" {
     24 		msg = xkcd.FetchThisXKCD(num)
     25 	} else if option == "save" {
     26 		msg = xkcd.SaveXKCD(num)
     27 	} else if option == "explain" {
     28 		msg = xkcd.ExplainXKCD(num)
     29 	} else {
     30 		msg = xkcd.DefaultBehaviour(option)
     31 	}
     32 	fmt.Print(msg)
     33 }