Repository: richardpenman/whois

Issue:
Allow providing cli options when `command=True`
Hi, I think it would be nice to allow providing some options to cli whois executable [here](https://github.com/richardpenman/whois/blob/0248325caee193fbb7d3a6174ab7a64eea83ff69/whois/__init__.py#L26) when `command=True`. By default, I suggest that we set `exec_opts="-H"` to clear the raw output from the wall of useless legal text.

Context: I intend to use this lib as a wrapper for a simple cli tool that shows only specific but enhanced whois data, and I will print raw text when facing lookup errors. But that wall of legal text makes such errors too noisy.

Hints from issue comments:
@richardpenman: Good idea - could you send a PR for this?

Solution patch:
diff --git a/whois/__init__.py b/whois/__init__.py
index a099dd3..87cbd1b 100644
--- a/whois/__init__.py
+++ b/whois/__init__.py
@@ -23,7 +23,7 @@ IPV4_OR_V6 = re.compile(
 )
 
 
-def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=False, convert_punycode=True):
+def whois(url, command=False, flags=0, executable="whois", executable_opts=None, inc_raw=False, quiet=False, convert_punycode=True):
     # clean domain to expose netloc
     ip_match = IPV4_OR_V6.match(url)
     if ip_match:
@@ -38,7 +38,13 @@ def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=
         domain = extract_domain(url)
     if command:
         # try native whois command
-        r = subprocess.Popen([executable, domain], stdout=subprocess.PIPE)
+        whois_command = [executable, domain]
+        if executable_opts:
+            if isinstance(executable_opts, list):
+                whois_command.extend(executable_opts)
+            else:
+                whois_command.append(executable_opts)
+        r = subprocess.Popen(whois_command, stdout=subprocess.PIPE)
         text = r.stdout.read().decode()
     else:
         # try builtin client
diff --git a/whois/parser.py b/whois/parser.py
index 59db06b..467736a 100644
--- a/whois/parser.py
+++ b/whois/parser.py
@@ -2077,6 +2077,7 @@ class WhoisAi(WhoisEntry):
     regex = {
         "domain_name": r"Domain Name\s*:\s*(.+)",
         "domain_id": r"Registry Domain ID\s*:\s*(.+)",
+        "status": r"Domain Status:\s*(.+)",
         "creation_date": r"Creation Date:\s*(.+)",
         "registrar": r"Registrar:\s*(.+)",
         "registrar_phone": r"Registrar Abuse Contact Phone:\s*(.+)",
@@ -3340,7 +3341,7 @@ class WhoisSite(WhoisEntry):
         "whois_server": r"Whois Server: *(.+)",
         "updated_date": r"Updated Date: *(.+)",
         "creation_date": r"Creation Date: *(.+)",
-        "expiration_date": r"Registrar Registration Expiration Date: *(.+)",
+        "expiration_date": r"Registry Expiry Date: *(.+)",
         "name_servers": r"Name Server: *(.+)",  # list of name servers
         "status": r"Domain Status: *(.+)",  # list of statuses
         "emails": EMAIL_REGEX,  # list of email s
@@ -3370,7 +3371,7 @@ class WhoisDesign(WhoisEntry):
         "whois_server": r"Registrar WHOIS Server: *(.+)",
         "updated_date": r"Updated Date: *(.+)",
         "creation_date": r"Creation Date: *(.+)",
-        "expiration_date": r"Registrar Registration Expiration Date: *(.+)",
+        "expiration_date": r"Registry Expiry Date: *(.+)",
         "name_servers": r"Name Server: *(.+)",  # list of name servers
         "status": r"Domain Status: *(.+)",  # list of statuses
         "emails": EMAIL_REGEX,  # list of email s


Test patch:
diff --git a/test/test_parser.py b/test/test_parser.py
index cc4dcbb..24fdb45 100644
--- a/test/test_parser.py
+++ b/test/test_parser.py
@@ -162,6 +162,9 @@ Domain Name: google.ai
 Registry Domain ID: 325702_nic_ai
 Registry WHOIS Server: whois.nic.ai
 Creation Date: 2017-12-16T05:37:20.801Z
+Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
+Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
+Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
 Registrar: Markmonitor
 Registrar Abuse Contact Email: ccops@markmonitor.com
 Registrar Abuse Contact Phone: +1.2083895740
@@ -266,6 +269,11 @@ DNSSEC: unsigned
             "tech_phone": "+1.6502530000",
             "tech_postal_code": "94043",
             "tech_state": "CA",
+            "status": [
+              "clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
+              "clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited",
+              "clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited"
+            ],
         }
         self._parse_and_compare("google.ai", data, expected_results)