/
cmd_tool_is_v4.go
56 lines (44 loc) · 1.1 KB
/
cmd_tool_is_v4.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"
"github.com/ipinfo/cli/lib/complete"
"github.com/ipinfo/cli/lib/complete/predict"
"github.com/spf13/pflag"
)
var completionsToolIsV4 = &complete.Command{
Flags: map[string]complete.Predictor{
"-h": predict.Nothing,
"--help": predict.Nothing,
"-q": predict.Nothing,
"--quiet": predict.Nothing,
},
}
func printHelpToolIsV4() {
fmt.Printf(
`Usage: %s tool is_v4 [<opts>] <cidr | ip | ip-range | filepath>
Description:
Checks if the input is an IPv4 address.
Inputs can be IPs, IP ranges, CIDRs, or filepath to a file
Examples:
# Check CIDR.
$ %[1]s tool is_v4 1.1.1.0/30
# Check IP range.
$ %[1]s tool is_v4 1.1.1.0-1.1.1.244
# Check for file.
$ %[1]s tool is_v4 /path/to/file.txt
# Check entries from stdin.
$ cat /path/to/file1.txt | %[1]s tool is_v4
Options:
--help, -h
show help.
--quiet, -q
quiet mode; suppress additional output.
`, progBase)
}
func cmdToolIsV4() (err error) {
f := lib.CmdToolIsV4Flags{}
f.Init()
pflag.Parse()
return lib.CmdToolIsV4(f, pflag.Args()[2:], printHelpToolIsV4)
}