-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
52 lines (43 loc) · 1.14 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 (
"github.com/huantt/kafka-dump/cmd"
"github.com/huantt/kafka-dump/pkg/log"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"os"
)
func main() {
if err := run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(args []string) error {
var logLevel string
rootCmd := &cobra.Command{}
rootCmd.PersistentFlags().StringVarP(&logLevel, "log-level", "", "info", "Log level")
logConfig := log.Config{Level: logLevel, Format: "text"}
logConfig.Build()
exportCommand, err := cmd.CreateExportCommand()
if err != nil {
return errors.Wrap(err, "Failed to create export command")
}
importCommand, err := cmd.CreateImportCmd()
if err != nil {
return errors.Wrap(err, "Failed to create import command")
}
streamCommand, err := cmd.CreateStreamCmd()
if err != nil {
return errors.Wrap(err, "Failed to create stream command")
}
countParquetNumberOfRowsCmd, err := cmd.CreateCountParquetRowCommand()
if err != nil {
return errors.Wrap(err, "Failed to create parquet row counter command")
}
rootCmd.AddCommand(
exportCommand,
importCommand,
streamCommand,
countParquetNumberOfRowsCmd,
)
return rootCmd.Execute()
}