-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
52 lines (44 loc) · 1.06 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
package main
import (
"fmt"
"github.com/pingcap-inc/tidb2dw/cmd"
"github.com/pingcap-inc/tidb2dw/version"
"github.com/spf13/cobra"
)
var rootCmd *cobra.Command
func init() {
rootCmd = &cobra.Command{
Use: "tidb2dw",
Short: "A service to replicate data changes from TiDB to Data Warehouse in real-time",
DisableFlagParsing: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return cmd.Help()
}
switch args[0] {
case "--help", "-h":
return cmd.Help()
case "--version", "-v":
fmt.Println(version.NewTiDB2DWVersion().String())
return nil
default:
return fmt.Errorf("unknown flag: %s\nRun `tidb2dw --help` for usage.", args[0])
}
},
}
rootCmd.Flags().BoolP("version", "v", false, "Print the version of tidb2dw")
rootCmd.AddCommand(
// replications
cmd.NewSnowflakeCmd(),
cmd.NewRedshiftCmd(),
cmd.NewBigQueryCmd(),
cmd.NewDatabricksCmd(),
// exporters
cmd.NewS3Cmd(),
cmd.NewGCSCmd(),
)
}
func main() {
rootCmd.Execute()
}