-
Notifications
You must be signed in to change notification settings - Fork 6
/
root.go
139 lines (120 loc) · 4.85 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/AccelByte/sample-apps/cmd/match2"
"github.com/AccelByte/sample-apps/cmd/reporting"
"github.com/AccelByte/sample-apps/cmd/session"
"github.com/AccelByte/sample-apps/cmd/achievement"
"github.com/AccelByte/sample-apps/cmd/ams"
"github.com/AccelByte/sample-apps/cmd/basic"
"github.com/AccelByte/sample-apps/cmd/challenge"
"github.com/AccelByte/sample-apps/cmd/chat"
"github.com/AccelByte/sample-apps/cmd/cloudsave"
"github.com/AccelByte/sample-apps/cmd/csm"
"github.com/AccelByte/sample-apps/cmd/dsartifact"
"github.com/AccelByte/sample-apps/cmd/dslogmanager"
"github.com/AccelByte/sample-apps/cmd/dsmc"
"github.com/AccelByte/sample-apps/cmd/gametelemetry"
"github.com/AccelByte/sample-apps/cmd/gdpr"
"github.com/AccelByte/sample-apps/cmd/group"
"github.com/AccelByte/sample-apps/cmd/iam"
"github.com/AccelByte/sample-apps/cmd/inventory"
"github.com/AccelByte/sample-apps/cmd/leaderboard"
"github.com/AccelByte/sample-apps/cmd/legal"
"github.com/AccelByte/sample-apps/cmd/lobby"
"github.com/AccelByte/sample-apps/cmd/matchmaking"
"github.com/AccelByte/sample-apps/cmd/platform"
"github.com/AccelByte/sample-apps/cmd/qosm"
"github.com/AccelByte/sample-apps/cmd/seasonpass"
"github.com/AccelByte/sample-apps/cmd/sessionbrowser"
"github.com/AccelByte/sample-apps/cmd/sessionhistory"
"github.com/AccelByte/sample-apps/cmd/social"
"github.com/AccelByte/sample-apps/cmd/ugc"
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)
var cfgFile string
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "sample-apps",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Hello CLI")
},
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cobra.CheckErr(RootCmd.Execute())
}
func init() {
cobra.OnInitialize(initConfig)
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sample-apps.yaml)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
// Parent Commands
RootCmd.AddCommand(achievement.AchievementCmd)
RootCmd.AddCommand(ams.AmsCmd)
RootCmd.AddCommand(basic.BasicCmd)
RootCmd.AddCommand(challenge.ChallengeCmd)
RootCmd.AddCommand(chat.ChatCmd)
RootCmd.AddCommand(cloudsave.CloudsaveCmd)
RootCmd.AddCommand(csm.CsmCmd)
RootCmd.AddCommand(dsmc.DsmcCmd)
RootCmd.AddCommand(dsartifact.DsartifactCmd)
RootCmd.AddCommand(dslogmanager.DslogmanagerCmd)
RootCmd.AddCommand(gametelemetry.GametelemetryCmd)
RootCmd.AddCommand(gdpr.GdprCmd)
RootCmd.AddCommand(group.GroupCmd)
RootCmd.AddCommand(iam.IamCmd)
RootCmd.AddCommand(inventory.InventoryCmd)
RootCmd.AddCommand(leaderboard.LeaderboardCmd)
RootCmd.AddCommand(legal.LegalCmd)
RootCmd.AddCommand(lobby.LobbyCmd)
RootCmd.AddCommand(match2.Match2Cmd)
RootCmd.AddCommand(matchmaking.MatchmakingCmd)
RootCmd.AddCommand(platform.PlatformCmd)
RootCmd.AddCommand(qosm.QosmCmd)
RootCmd.AddCommand(reporting.ReportingCmd)
RootCmd.AddCommand(seasonpass.SeasonpassCmd)
RootCmd.AddCommand(session.SessionCmd)
RootCmd.AddCommand(sessionbrowser.SessionbrowserCmd)
RootCmd.AddCommand(sessionhistory.SessionhistoryCmd)
RootCmd.AddCommand(social.SocialCmd)
RootCmd.AddCommand(ugc.UgcCmd)
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
cobra.CheckErr(err)
// Search config in home directory with name ".sample-apps" (without extension).
viper.AddConfigPath(home)
viper.SetConfigName(".sample-apps")
}
viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
_, _ = fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
}
}