-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroot.go
46 lines (40 loc) · 1.23 KB
/
root.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
package cmd
import (
"github.com/notdodo/IAMme-IAMme/pkg/infra/neo4j"
"github.com/notdodo/IAMme-IAMme/pkg/io/logging"
"github.com/spf13/cobra"
)
const (
flagVerbose = "verbose"
flagDebug = "debug"
flagOrgURL = "org-url"
flagOktaClientToken = "client-token"
)
var (
logger logging.LogManager
orgUrl string
oktaClientToken string
neo4jClient neo4j.Neo4jClient
rootCmd = &cobra.Command{
Use: "iamme",
Short: "A CLI tool to interact with Okta and Neo4j",
}
)
func init() {
logger = logging.GetLogManager()
rootCmd.PersistentFlags().BoolP(flagVerbose, "v", false, "Verbose output")
rootCmd.PersistentFlags().BoolP(flagDebug, "d", false, "Debug output")
rootCmd.PersistentFlags().StringVarP(&orgUrl, flagOrgURL, "u", "", "Okta Org URL")
rootCmd.PersistentFlags().StringVarP(&oktaClientToken, flagOktaClientToken, "c", "", "Okta Client Token")
}
func Execute(neo4j neo4j.Neo4jClient) {
neo4jClient = neo4j
if err := rootCmd.Execute(); err != nil {
logger.Error("Error executing command", "err", err)
}
}
func markAsRequired(flag string) {
if err := rootCmd.MarkFlagRequired(flag); err != nil {
logger.Error("Required flags not provided", "err", err, "flag", flag)
}
}