diff --git a/README.md b/README.md index 13af0a5..28fd431 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A user-friendly IRC bouncer. ## Usage - go run ./cmd/sojuctl create-user + go run ./cmd/sojuctl create-user -admin go run ./cmd/soju -listen irc+insecure://127.0.0.1:6667 Then connect with username `/chat.freenode.net` and join `#soju`. diff --git a/cmd/sojuctl/main.go b/cmd/sojuctl/main.go index d7bcdeb..334cfa1 100644 --- a/cmd/sojuctl/main.go +++ b/cmd/sojuctl/main.go @@ -15,9 +15,9 @@ import ( const usage = `usage: sojuctl [-config path] [options...] - create-user Create a new user - change-password Change password for a user - help Show this help message + create-user [-admin] Create a new user + change-password Change password for a user + help Show this help message ` func init() { @@ -55,6 +55,10 @@ func main() { os.Exit(1) } + fs := flag.NewFlagSet("", flag.ExitOnError) + admin := fs.Bool("admin", false, "make the new user admin") + fs.Parse(flag.Args()[2:]) + password, err := readPassword() if err != nil { log.Fatalf("failed to read password: %v", err) @@ -68,6 +72,7 @@ func main() { user := soju.User{ Username: username, Password: string(hashed), + Admin: *admin, } if err := db.StoreUser(&user); err != nil { log.Fatalf("failed to create user: %v", err)