From 7886656fb329afbee9466ccb6b9fad21331bc6c9 Mon Sep 17 00:00:00 2001 From: "Benjamin S. Allen" Date: Tue, 9 Mar 2021 09:25:16 -0600 Subject: [PATCH] Add setting realName attribute via create and modify user --- README.md | 6 +++++- cmd/duocli/duocli.go | 6 ++++-- pkg/cli/user/user.go | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 10ae6fc..9e88835 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # NAME -duocli - CLI Interface to Duo Admin API +duocli - CLI Interface to Duo Admin API: https://duo.com/docs/adminapi # SYNOPSIS @@ -47,6 +47,8 @@ create a user **--lastName, -l**="": last name of user +**--realName, -r**="": real name of user + **--status, -s**="": status of user: active, disabled, or bypass (default: active) **--username, -u**="": username @@ -73,6 +75,8 @@ modify a user's attributes, add or remove group membership **--lastName, -l**="": last name of user +**--realName, -r**="": real name of user + **--status, -s**="": status of user: active, disabled, or bypass **--username, -u**="": username diff --git a/cmd/duocli/duocli.go b/cmd/duocli/duocli.go index 97c2c39..fd8463c 100644 --- a/cmd/duocli/duocli.go +++ b/cmd/duocli/duocli.go @@ -16,7 +16,7 @@ func main() { app := &cli.App{ Name: "duocli", - Usage: "CLI Interface to Duo Admin API", + Usage: "CLI Interface to Duo Admin API: https://duo.com/docs/adminapi", Version: version, HideHelpCommand: true, EnableBashCompletion: true, @@ -42,6 +42,7 @@ func main() { &cli.StringFlag{Name: "username", Aliases: []string{"u"}, Required: true, Usage: "username"}, &cli.StringSliceFlag{Name: "group", Aliases: []string{"g"}, Usage: "add user to group, can be specified multiple times to add user to multiple groups"}, &cli.StringFlag{Name: "email", Aliases: []string{"e"}, Usage: "email address of user"}, + &cli.StringFlag{Name: "realName", Aliases: []string{"r"}, Usage: "real name of user"}, &cli.StringFlag{Name: "firstName", Aliases: []string{"f"}, Usage: "first name of user"}, &cli.StringFlag{Name: "lastName", Aliases: []string{"l"}, Usage: "last name of user"}, &cli.StringFlag{Name: "status", Aliases: []string{"s"}, Usage: "status of user: active, disabled, or bypass", Value: "active"}, @@ -64,6 +65,7 @@ func main() { &cli.StringSliceFlag{Name: "addgroup", Aliases: []string{"g"}, Usage: "add user to groups, adds to existing memberships, and can be specified multiple times to add user to multiple groups"}, &cli.StringSliceFlag{Name: "delgroup", Aliases: []string{"G"}, Usage: "remove user from groups, removes from existing memberships, and can be specified multiple times to remove user from multiple groups"}, &cli.StringFlag{Name: "email", Aliases: []string{"e"}, Usage: "email address of user"}, + &cli.StringFlag{Name: "realName", Aliases: []string{"r"}, Usage: "real name of user"}, &cli.StringFlag{Name: "firstName", Aliases: []string{"f"}, Usage: "first name of user"}, &cli.StringFlag{Name: "lastName", Aliases: []string{"l"}, Usage: "last name of user"}, &cli.StringFlag{Name: "status", Aliases: []string{"s"}, Usage: "status of user: active, disabled, or bypass"}, @@ -94,7 +96,7 @@ func main() { Hidden: true, Action: docs.Readme, Flags: []cli.Flag{ - &cli.StringFlag{Name: "output", Required: true, Usage: "path to write man page"}, + &cli.StringFlag{Name: "output", Required: true, Usage: "path to write readme"}, }, }, }, diff --git a/pkg/cli/user/user.go b/pkg/cli/user/user.go index 97bc28d..bac4271 100644 --- a/pkg/cli/user/user.go +++ b/pkg/cli/user/user.go @@ -18,6 +18,7 @@ func Create(c *cli.Context) error { groups := c.StringSlice("group") email := c.String("email") + realName := c.String("realName") firstName := c.String("firstName") lastName := c.String("lastName") status := c.String("status") @@ -43,6 +44,7 @@ func Create(c *cli.Context) error { user := admin.User{ Username: username, Email: email, + RealName: &realName, FirstName: &firstName, LastName: &lastName, Status: status, @@ -65,6 +67,7 @@ func Modify(c *cli.Context) error { addgroups := c.StringSlice("addgroup") delgroups := c.StringSlice("delgroup") email := c.String("email") + realName := c.String("realName") firstName := c.String("firstName") lastName := c.String("lastName") status := c.String("status") @@ -100,6 +103,7 @@ func Modify(c *cli.Context) error { user := admin.User{ Username: username, Email: email, + RealName: &realName, FirstName: &firstName, LastName: &lastName, Status: status,