-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
74 lines (68 loc) · 1.33 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"fmt"
"github.com/urfave/cli"
"helpers"
"log"
"os"
)
func SingleAdd(c *cli.Context) error {
srv, err := helpers.GetService()
if err != nil {
log.Fatalf("Unable to create service, Error is : %v", err)
}
helpers.Addemails(c.String("email"), c.String("group"), srv)
fmt.Printf("Added Email %v to the group" , c.String("email"))
return nil
}
func MultipleAdd(c *cli.Context) error {
fmt.Println("Adding Emails!")
helpers.JsonAdd(c.String("SaPath"), c.String("group"))
return nil
}
func main() {
app := cli.NewApp()
app.Name = "Google Group Utility"
app.Usage = "A minimal program written in GoLang to add members to gsuite groups."
app.Authors = []*cli.Author{
{Name:"Shubham Dubey",},
}
multiple := []cli.Flag{
&cli.StringFlag{
Name:"SaPath",
Value:"accounts",
},
&cli.StringFlag{
Name:"group",
Value:"",
},
}
single:= []cli.Flag{
&cli.StringFlag{
Name:"email",
Value:"",
},
&cli.StringFlag{
Name:"group",
Value:"",
},
}
app.Commands = cli.Commands{
{
Name:"single",
Usage:"Add single email to your google group.",
Flags:single,
Action:SingleAdd,
},
{
Name:"multiple",
Usage:"Add multiple emails from jsons to your google group.",
Flags:multiple,
Action:MultipleAdd,
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}