-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
61 lines (53 loc) · 1.88 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
package main
import (
"GADS/hub"
"GADS/provider"
"fmt"
"os"
"github.com/spf13/cobra"
)
var AppVersion = "development"
func main() {
var rootCmd = &cobra.Command{Use: "GADS"}
rootCmd.PersistentFlags().String("mongo-db", "localhost:27017", "The address of the MongoDB instance")
// Hub Command
var hubCmd = &cobra.Command{
Use: "hub",
Short: "Run a hub component",
Run: func(cmd *cobra.Command, args []string) {
hub.StartHub(cmd.Flags(), AppVersion)
},
}
hubCmd.Flags().String("host-address", "localhost", "The IP address of the host machine")
hubCmd.Flags().String("port", "", "The port on which the component should run")
hubCmd.Flags().String("ui-files-dir", "", "Directory where the UI static files will be unpacked and served from."+
"\nBy default app will try to use a temp dir on the host, use this flag only if you encounter issues with the temp folder."+
"\nAlso you need to have created the folder in advance!")
rootCmd.AddCommand(hubCmd)
// Provider Command
var providerCmd = &cobra.Command{
Use: "provider",
Short: "Run a provider component",
Run: func(cmd *cobra.Command, args []string) {
provider.StartProvider(cmd.Flags())
},
}
providerCmd.Flags().String("nickname", "", "Nickname of the provider")
providerCmd.Flags().String("provider-folder", ".", "The folder where logs and other data will be stored")
providerCmd.Flags().String("log-level", "info", "The verbosity of the logs of the provider instance")
providerCmd.Flags().String("hub", "", "The address of the GADS hub instance")
rootCmd.AddCommand(providerCmd)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the application version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(AppVersion)
},
}
rootCmd.AddCommand(versionCmd)
// Execute the root command
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}