Repository: certbot/certbot

Issue:
AssertionError: Action corresponding to argument -  is None
## My operating system is (include version):
Ubuntu 22.04

## I installed Certbot with (snap, OS package manager, pip, certbot-auto, etc):
Running via docker, using certbot/dns-cloudflare:arm64v8-v2.7.2. No Error if I'm running v2.7.1

## I ran this command and it produced this output:
docker compose up -d using the below compose file (works with v2.7.1)
image: certbot/dns-cloudflare:arm64v8-v2.7.2
    container_name: xxxx
    platform: linux/arm64/v8
    hostname: xxxx
    user: 1000:1003
    restart: unless-stopped
    network_mode: host
    environment:
      - TZ=America/New_York
    volumes:
      - ./data/certbot/etc-letsencrypt:/etc/letsencrypt
      - ./data/certbot/var-lib-letsencrypt:/var/lib/letsencrypt
      - ./data/certbot/var-log-letsencrypt:/var/log/letsencrypt
      - type: bind
        source: ./data/certbot/cloudflare.ini
        target: /conf/cloudflare.ini
    command:
      - certonly  #don't install
      - -n  #non-interactive
      - --agree-tos
      - --dns-cloudflare
      - --email=xxxx
      - --dns-cloudflare-credentials=/conf/cloudflare.ini
      - --dns-cloudflare-propagation-seconds=30
      - -d xxxx
      - -v  #Verbose



## Certbot's behavior differed from what I expected because:
I receive and error instead of a successful message telling me the certificate is not yet due for renewal

## Here is a Certbot log showing the issue (if available):
###### Logs are stored in `/var/log/letsencrypt` by default. Feel free to redact domains, e-mail and IP addresses as you see fit.

## Here is the relevant nginx server block or Apache virtualhost for the domain I am configuring:



Discussion:
Thanks for the bug report. To help me investigate this better, could you enclose your `docker-compose.yml` in backticks (\`\`\`) to preserve its exact formatting, and include the full error traceback text?
A redacted version of your cloudflare.ini file would also help a ton
Actually, i think i see what's happening here. @PhilM-IT could you try running this again with an equals sign in your `-d xxxx` line, like `-d=xxxx`?

Resolving patch:
diff --git a/certbot/certbot/_internal/cli/helpful.py b/certbot/certbot/_internal/cli/helpful.py
--- a/certbot/certbot/_internal/cli/helpful.py
+++ b/certbot/certbot/_internal/cli/helpful.py
@@ -219,6 +219,8 @@ def update_result(settings_dict: Dict[str, Tuple[configargparse.Action, str]],
 
                 if '=' in arg:
                     arg = arg.split('=')[0]
+                elif ' ' in arg:
+                    arg = arg.split(' ')[0]
 
                 if arg.startswith('--'):
                     args.append(arg)


Test patch:
diff --git a/certbot/certbot/_internal/tests/cli_test.py b/certbot/certbot/_internal/tests/cli_test.py
--- a/certbot/certbot/_internal/tests/cli_test.py
+++ b/certbot/certbot/_internal/tests/cli_test.py
@@ -594,6 +594,13 @@ def test_adjacent_short_args(self):
         assert_set_by_user_with_value(namespace, 'text_mode', True)
         assert_set_by_user_with_value(namespace, 'verbose_count', 1)
         assert_set_by_user_with_value(namespace, 'email', 'foo@example.com')
+    
+    def test_arg_with_contained_spaces(self):
+        # This can happen if a user specifies an arg like "-d foo.com" enclosed
+        # in double quotes, or as its own line in a docker-compose.yml file (as
+        # in #9811)
+        namespace = self.parse(['certonly', '-d foo.com'])
+        assert_set_by_user_with_value(namespace, 'domains', ['foo.com'])
 
 if __name__ == '__main__':
     sys.exit(pytest.main(sys.argv[1:] + [__file__]))  # pragma: no cover