forked from influxdata/flux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (36 loc) · 806 Bytes
/
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
package main
import (
"fmt"
"os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var version int
var rootCmd = &cobra.Command{
Use: "influxql-decode",
Short: "InfluxQL JSON -> v1 line protocol format or v2 csv format.",
Long: "Decode InfluxQL JSON output files and convert them to v1 line protocol format or v2 csv format.",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return cmd.Help()
}
switch version {
case 1:
return v1(cmd, args)
case 2:
return v2(cmd, args)
default:
return errors.New("Target version can only be 1 or 2.")
}
},
}
func init() {
rootCmd.PersistentFlags().IntVarP(&version, "version", "v", 2,
"target version")
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}