Improved shell commandline for anime sync
This commit is contained in:
50
jobs/sync-anime/shell.go
Normal file
50
jobs/sync-anime/shell.go
Normal file
@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
// Shell parameters
|
||||
var animeID string
|
||||
var verbose bool
|
||||
|
||||
// Shell flags
|
||||
func init() {
|
||||
flag.StringVar(&animeID, "id", "", "ID of the anime that you want to refresh")
|
||||
flag.BoolVar(&verbose, "v", false, "Verbose output")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
// InvokeShellArgs ...
|
||||
func InvokeShellArgs() bool {
|
||||
if animeID != "" {
|
||||
kitsuAnime, err := kitsu.GetAnime(animeID)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if kitsuAnime.ID != animeID {
|
||||
panic(errors.New("Anime ID is not the same"))
|
||||
}
|
||||
|
||||
anime := sync(kitsuAnime)
|
||||
|
||||
if verbose {
|
||||
color.Cyan("Kitsu:")
|
||||
arn.PrettyPrint(kitsuAnime)
|
||||
|
||||
color.Cyan("ARN:")
|
||||
arn.PrettyPrint(anime)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user