50 lines
960 B
Go
Raw Normal View History

2018-04-12 17:05:05 +00:00
package main
import (
"flag"
"github.com/animenotifier/arn"
)
// Shell parameters
2018-10-31 23:23:41 +00:00
var objectType string
var objectID string
2018-04-12 17:05:05 +00:00
// Shell flags
func init() {
2018-10-31 23:23:41 +00:00
flag.StringVar(&objectType, "type", "all", "all | anime | character")
flag.StringVar(&objectID, "id", "", "ID of the notify.moe anime/character you want to refresh")
2018-04-12 17:05:05 +00:00
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
2018-10-31 23:23:41 +00:00
if objectID != "" {
switch objectType {
case "anime":
anime, err := arn.GetAnime(objectID)
arn.PanicOnError(err)
2018-04-12 17:05:05 +00:00
2018-10-31 23:23:41 +00:00
if anime.GetMapping("myanimelist/anime") == "" {
panic("No MAL ID")
}
syncAnime(anime, anime.GetMapping("myanimelist/anime"))
case "character":
character, err := arn.GetCharacter(objectID)
arn.PanicOnError(err)
if character.GetMapping("myanimelist/character") == "" {
panic("No MAL ID")
}
2018-04-12 17:05:05 +00:00
2018-10-31 23:23:41 +00:00
syncCharacter(character, character.GetMapping("myanimelist/character"))
2018-04-12 17:05:05 +00:00
}
return true
}
return false
}