import nmap3
import json


def scanner(theTarget, theScan):
    nmapOBJ = nmap3.Nmap()
    if theScan == "default":
        results = nmapOBJ.scan_top_ports(theTarget)
        results = json.dumps(results, indent = 1, sort_keys=True)
        return results
    else:
        # For now no other scan types available
        pass


def init():
    target = input("Enter the target ip address:\n")
    scanType = input("Enter the scan type:\n")

    if scanType == '':
        scanType = "default"
    if target == '':
        print("No targets found, please enter one")
        init()

    theResult = scanner(target, scanType)

    return theResult


if __name__ == "__main__":
    print(init())
