restructure as submodules

This commit is contained in:
2021-11-16 15:18:19 -06:00
parent b5450aa278
commit 1267a8f4e3
6 changed files with 66 additions and 84 deletions

35
main.go
View File

@@ -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, ",")
}
}