-
Notifications
You must be signed in to change notification settings - Fork 16
/
cmd_read.go
56 lines (47 loc) · 1.09 KB
/
cmd_read.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
package main
import (
"fmt"
"github.com/ipinfo/cli/lib/complete"
"github.com/ipinfo/cli/lib/complete/predict"
mmdbLib "github.com/ipinfo/mmdbctl/lib"
"github.com/spf13/pflag"
)
var predictReadFmts = []string{
"json",
"json-compact",
"json-pretty",
"tsv",
"csv",
}
var completionsRead = &complete.Command{
Flags: map[string]complete.Predictor{
"--nocolor": predict.Nothing,
"-h": predict.Nothing,
"--help": predict.Nothing,
"-f": predict.Set(predictReadFmts),
"--format": predict.Set(predictReadFmts),
},
}
func printHelpRead() {
fmt.Printf(
`Usage: %s read [<opts>] <ip | ip-range | cidr | filepath> <mmdb>
Options:
General:
--nocolor
disable colored output.
--help, -h
show help.
Format:
-f <format>, --format <format>
the output format.
can be "json", "json-compact", "json-pretty", "tsv" or "csv".
note that "json" is short for "json-compact".
default: json.
`, progBase)
}
func cmdRead() error {
f := mmdbLib.CmdReadFlags{}
f.Init()
pflag.Parse()
return mmdbLib.CmdRead(f, pflag.Args()[1:], printHelpRead)
}