-
Notifications
You must be signed in to change notification settings - Fork 1
/
add.go
40 lines (32 loc) · 799 Bytes
/
add.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package member
import (
"log"
"github.com/urfave/cli"
"github.com/garlsecurity/securepassctl/spctl/service"
)
func init() {
Command.Subcommands = append(Command.Subcommands,
cli.Command{
Name: "add",
Usage: "add group",
ArgsUsage: "USERNAME GROUP",
Description: "Add a user to a group.",
Action: ActionAdd,
Flags: []cli.Flag{},
})
}
// ActionAdd provides the add subcommand
func ActionAdd(c *cli.Context) {
if len(c.Args()) != 2 {
log.Fatal("error: must specify a username and a group")
}
username := c.Args()[0]
group := c.Args()[1]
if c.Bool("debug") {
log.Printf("Adding user %s to group %s\n", username, group)
}
_, err := service.Service.GroupMemberAdd(username, group)
if err != nil {
log.Fatalf("error: %v", err)
}
}