Made change-role patch accept CLI arguments

This commit is contained in:
Eduard Urbach 2019-04-19 16:44:37 +09:00
parent 8849449c4a
commit db72609650

View File

@ -1,13 +1,30 @@
package main package main
import ( import (
"flag"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
) )
// 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()
}
func main() { func main() {
defer arn.Node.Close() defer arn.Node.Close()
user, _ := arn.GetUser("Vy2Hk5yvx") // Get user
user.Role = "" user, err := arn.GetUser(userID)
arn.PanicOnError(err)
// Save role
user.Role = role
user.Save() user.Save()
} }