import richparser

class CLI:
    def __init__(self) -> None:
        self.cli = richparser.RichParser(description="Khonshu – A stealthy, concurrent Python port scanner crafted for speed and accuracy.", auto=False)

    def build(self):
        self.cli.add_argument("input", "-host", "--host", type=str, help="hosts to scan for open ports and supports comma separated values")
        self.cli.add_argument("input", "-list", "--list", type=str, help="file that contains list of host to scan for open ports")
        self.cli.add_argument("input", "-exclude-hosts", type=str, help="hosts to exclude from the open port scan and supports comma separated values", default="")
        self.cli.add_argument("input", "-resume", "--resume", type=str, help="resume file generated by khonshu to continue the port scanning ")
        self.cli.add_argument("port", "-port", "--port", type=str, help="ports to scan (80,443 1-65535)")
        self.cli.add_argument("port", "-top-ports", "--top-ports", type=str, help="top port numbers to scan (100,1000,full-port)",default="100")
        self.cli.add_argument("port", "-port-file", "--port-file", type=str, help="file that contains list of port numbers to scan")
        self.cli.add_argument("port", "-ep", "--exclude-ports", type=str,help="port numbers to exclude from port scanning and supports comma separated values", default="")
        self.cli.add_argument("port", "-tcpt", "--tcp-ports", type=str, help="comma-separated TCP port(s) to use for checking host availability via TCP SYN/ACK pings (e.g., 80,443,8080)", default="80,443,8080")
        self.cli.add_argument("port", "-pst", "--port-state", type=str, help="show only ports matching the specified state (e.g. open,closed,filtered,unfiltered,open|filtered) (default: open).",default="open,unfiltered")
        self.cli.add_argument("output", "-o", "--output", type=str,help="filename to save the open port scan results")
        self.cli.add_argument("output", "-j","--json", action="store_true", help="enabled the output in json format")
        self.cli.add_argument("rate-limit", "-c", "--concurrency", type=int, help="set the concurrency level for concurrent port scanning (default: 100)", default=100)
        self.cli.add_argument("rate-limit", "-rt", "--rate-limit", type=int, help="set a rate limit for sending a maximum number of requests per second (default: 1000)", default=1000)
        self.cli.add_argument("updates", "-up", "--update", action="store_true", help="update the khonshu to the latest version")
        self.cli.add_argument("updates", "-sup", "--show-updates", action="store_true", help="show the latest updates of khonshu")
        self.cli.add_argument("host-discovery", "-Sn", "--host-discovery", action="store_true", help="perform only host discovery and skips the port scan")
        self.cli.add_argument("host-discovery", "-Pn", "--skip-discovery", action="store_true", help="skip the host discovery and directly perform port scan")
        self.cli.add_argument("host-discovery", "-En", "--enable-discovery", action="store_true", help="enable the host discovery before port scanning")
        self.cli.add_argument("host-discovery", "-tcp-syn", "--tcp-syn-ping", action="store_true", help="performs TCP SYN ping on host (requires: -En and -Sn)")
        self.cli.add_argument("host-discovery", "-tcp-ack", "--tcp-ack-ping", action="store_true", help="performs TCP ACK ping on host (requires: -En and -Sn)")
        self.cli.add_argument("host-discovery", "-icmp-ping", "--icmp-echo-ping", action="store_true", help="performs ICMP echo request on host (requires -En and -Sn)")
        self.cli.add_argument("host-discovery", "-it-ping", "--icmp-timestamp-ping", action="store_true", help="performs ICMP timestamp ping request on host (requires -En and -Sn)")
        self.cli.add_argument("host-discovery", "-iam-ping", "--icmp-address-mask-ping", action="store_true", help="performs ICMP address mask ping request on host (requires -En and -Sn)")
        self.cli.add_argument("host-discovery", "-arp", "--arp-ping", action="store_true", help="performs Address Resolution Protocol ping request on host (requires -En and -Sn)")
        self.cli.add_argument("configuration", "-scan", "--scan-type", type=str, help="type of port scan we need to do (supports: connect,syn)",choices=["connect","syn"], default="connect")
        self.cli.add_argument("configuration", "-all-ips", "--scan-all-ips", action="store_true", help="scan all ips of associated DNS record of the domain")
        self.cli.add_argument("configuration", "-passive", "--passive", action="store_true", help="run passive open port scanning using shodan Internet DB API")
        self.cli.add_argument("configuration", "-il", "--interface-list", action="store_true", help="display the list of available interfaces")
        self.cli.add_argument("configuration", "-i", "--interface", type=str, help="network interface to use for port scan")
        self.cli.add_argument("configuration", "-resolver", "--resolver", type=str,help="custom DNS resolver to use for dns resolution")
        self.cli.add_argument("optimization", "-to", "--timeout", type=float, help="seconds to wait for port scanning timeout (default: 1)", default=1)
        self.cli.add_argument("optimization", "-retry", "--retry", type=int, help="number of retries for open port scanning", default=1)
        self.cli.add_argument("optimization", "-ping", "--ping",action="store_true",help="ping and verify host for port scan (default: false)")
        self.cli.add_argument("debug", "-hc", "--health-check", action="store_true", help="run the health check for the khonshu")
        self.cli.add_argument("debug", "-debug", "--debug", action="store_true", help="display the debugging information (debug option is specially for contributors and devs to understand the workflow of khonshu)")
        self.cli.add_argument("debug", "-verbose", "--verbose", action="store_true", help="increase the verbosity of khonshu")
        self.cli.add_argument("debug", "-version", "--version", action="store_true", help="shows the version of the khonshu")
        self.cli.add_argument("debug", "-silent", "--silent", action="store_true", help="shows only the port scanning results")
        self.cli.add_argument("debug", "-stats", "--stats", action="store_true",help="logs the progress of the khonshu")
        self.cli.add_argument("debug", "-nc", "--no-color", action="store_true", help="disables the colored output of the khonshu", default=False)
        return self.cli.parse_args()