2018-03-16 00:31:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-19 07:44:37 +00:00
|
|
|
"flag"
|
|
|
|
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-03-16 00:31:17 +00:00
|
|
|
)
|
|
|
|
|
2019-04-19 07:44:37 +00:00
|
|
|
// Shell parameters
|
|
|
|
var userID string
|
|
|
|
var role string
|
|
|
|
|
|
|
|
// Shell flags
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&userID, "id", "", "ID of the user")
|
|
|
|
flag.StringVar(&role, "role", "", "The user's new role")
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
2018-03-16 00:31:17 +00:00
|
|
|
func main() {
|
|
|
|
defer arn.Node.Close()
|
|
|
|
|
2019-04-19 07:46:22 +00:00
|
|
|
// Show usage if needed
|
|
|
|
if userID == "" || role == "" {
|
|
|
|
flag.Usage()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-04-19 07:44:37 +00:00
|
|
|
// Get user
|
|
|
|
user, err := arn.GetUser(userID)
|
|
|
|
arn.PanicOnError(err)
|
|
|
|
|
|
|
|
// Save role
|
|
|
|
user.Role = role
|
2018-03-16 00:31:17 +00:00
|
|
|
user.Save()
|
|
|
|
}
|