50 lines
866 B
Go
Raw Normal View History

2018-07-03 03:27:34 +00:00
package main
import (
"flag"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
// Shell parameters
var nick string
var service string
var serviceID string
// Shell flags
func init() {
flag.StringVar(&nick, "nick", "", "Nick of the user")
flag.StringVar(&service, "service", "", "Service name (Google or Facebook)")
flag.StringVar(&serviceID, "serviceID", "", "ID of the user on the given service")
flag.Parse()
}
func main() {
if nick == "" || service == "" || serviceID == "" {
flag.Usage()
return
}
color.Yellow("Updating user service ID")
defer color.Green("Finished.")
defer arn.Node.Close()
user, err := arn.GetUserByNick(nick)
arn.PanicOnError(err)
switch service {
case "Google":
user.ConnectGoogle(serviceID)
case "Facebook":
user.ConnectFacebook(serviceID)
default:
panic("Unknown service")
}
user.Save()
}