restructure as submodules
This commit is contained in:
35
main.go
35
main.go
@@ -1,6 +1,11 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"lookupip/src/ipapi"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var verbose bool = false
|
||||
var detail bool
|
||||
@@ -13,13 +18,37 @@ func main() {
|
||||
if verbose {
|
||||
fmt.Println("Verbose mode on")
|
||||
}
|
||||
data, err := lookup(ip, properties)
|
||||
data, err := ipapi.Lookup(ip, properties)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
result := getProperties(data)
|
||||
result := ipapi.GetProperties(data, properties, detail)
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func parseFlags() {
|
||||
_ip := flag.String("ip", "", "IP address to lookup")
|
||||
_props := flag.String("p", "Country", "Properties to retrieve")
|
||||
flag.BoolVar(&detail, "d", false, "Show Detail")
|
||||
_verbose := flag.Bool("v", false, "Verbose output")
|
||||
flag.Parse()
|
||||
_loose := flag.Args()
|
||||
|
||||
if *_verbose {
|
||||
verbose = true
|
||||
}
|
||||
if *_ip == "" {
|
||||
if len(_loose) == 0 {
|
||||
} else {
|
||||
ip = _loose[0]
|
||||
}
|
||||
} else {
|
||||
ip = *_ip
|
||||
}
|
||||
if _props != nil {
|
||||
properties = strings.Split(*_props, ",")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user