-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (58 loc) · 1.22 KB
/
main.go
File metadata and controls
71 lines (58 loc) · 1.22 KB
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
package main
import (
"fmt"
"os"
"sort"
common "github.com/apiheat/akamai-cli-common"
edgegrid "github.com/apiheat/go-edgegrid"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
apiClient *edgegrid.Client
appName, appVer string
)
// Constants
const (
padding = 3
)
func main() {
app := common.CreateNewApp(appName, "A CLI to interact with Akamai Identity Management", appVer)
app.Flags = common.CreateFlags()
app.Commands = []cli.Command{
{
Name: "list",
Aliases: []string{"ls"},
Usage: "Get a list of [subcommand]]",
Subcommands: []cli.Command{
{
Name: "users",
Usage: "... users",
Action: cmdUsers,
Flags: []cli.Flag{
cli.StringFlag{
Name: "output",
Value: "markdown",
Usage: "Output format",
},
},
},
},
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
app.Before = func(c *cli.Context) error {
var err error
apiClient, err = common.EdgeClientInit(c.GlobalString("config"), c.GlobalString("section"), c.GlobalString("debug"))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}