Repository: microsoft/ptvsd

Issue:
Changes in CLI arguments between versions
## Environment data

- PTVSD version: 4.1.3
- Using VS Code or Visual Studio: N/A

## Actual behavior

* CLI args for starting apps for remote debugging has changed 
* Now the arg requires `--server-host`, this wasn't the case in the past.
* This is a breaking change.

## Expected  behavior

* We need to revert if possible as existing users will not be able to use PTSVD for remote debugging scenarios.

Reported here https://github.com/Microsoft/vscode-python/issues/2833#issuecomment-428422616



Discussion:
Please feel free to change the Priority label.
FWIW I think the `--server-host` came in on the previous version? I could not get remote debugging working with 2018.8.0 / 4.1.2, and specifically waited for these combination of versions to work again, so please don't just revert if you can manage it.
> so please don't just revert if you can manage it.

No decision had been made yet.

Sorry, I realised that, just providing a bit of extra context. I'm super excited to have remote debugging for django in docker!

Resolving patch:
diff --git a/ptvsd/__main__.py b/ptvsd/__main__.py
--- a/ptvsd/__main__.py
+++ b/ptvsd/__main__.py
@@ -24,8 +24,6 @@
 
 PYDEVD_OPTS = {
     '--file',
-    '--client',
-    #'--port',
     '--vm_type',
 }
 
@@ -45,8 +43,8 @@
 }
 
 USAGE = """
-  {0} [-h] [-V] [--nodebug] [--host HOST | --server-host HOST] --port PORT -m MODULE [arg ...]
-  {0} [-h] [-V] [--nodebug] [--host HOST | --server-host HOST] --port PORT FILENAME [arg ...]
+  {0} [-h] [-V] [--nodebug] [--client] [--host HOST] --port PORT -m MODULE [arg ...]
+  {0} [-h] [-V] [--nodebug] [--client] [--host HOST] --port PORT FILENAME [arg ...]
   {0} [-h] [-V] --host HOST --port PORT --pid PROCESS_ID
 """  # noqa
 
@@ -106,9 +104,7 @@ def _group_args(argv):
         if gottarget:
             script = argv[i:] + script
             break
-        if arg == '--client':
-            arg = '--host'
-        elif arg == '--file':
+        if arg == '--file':
             if nextarg is None:  # The filename is missing...
                 pydevd.append(arg)
                 continue  # This will get handled later.
@@ -131,14 +127,14 @@ def _group_args(argv):
             supported.append(arg)
 
         # ptvsd support
-        elif arg in ('--host', '--server-host', '--port', '--pid', '-m'):
+        elif arg in ('--host', '--port', '--pid', '-m'):
             if arg == '-m' or arg == '--pid':
                 gottarget = True
             supported.append(arg)
             if nextarg is not None:
                 supported.append(nextarg)
             skip += 1
-        elif arg in ('--single-session', '--wait'):
+        elif arg in ('--single-session', '--wait', '--client'):
             supported.append(arg)
         elif not arg.startswith('-'):
             supported.append(arg)
@@ -159,10 +155,9 @@ def _parse_args(prog, argv):
     )
 
     parser.add_argument('--nodebug', action='store_true')
+    parser.add_argument('--client', action='store_true')
 
-    host = parser.add_mutually_exclusive_group()
-    host.add_argument('--host')
-    host.add_argument('--server-host')
+    parser.add_argument('--host')
     parser.add_argument('--port', type=int, required=True)
 
     target = parser.add_mutually_exclusive_group(required=True)
@@ -179,17 +174,10 @@ def _parse_args(prog, argv):
     args = parser.parse_args(argv)
     ns = vars(args)
 
-    serverhost = ns.pop('server_host', None)
-    clienthost = ns.pop('host', None)
-    if serverhost:
-        args.address = Address.as_server(serverhost, ns.pop('port'))
-    elif not clienthost:
-        if args.nodebug:
-            args.address = Address.as_client(clienthost, ns.pop('port'))
-        else:
-            args.address = Address.as_server(clienthost, ns.pop('port'))
-    else:
-        args.address = Address.as_client(clienthost, ns.pop('port'))
+    host = ns.pop('host', None)
+    port = ns.pop('port')
+    client = ns.pop('client')
+    args.address = (Address.as_client if client else Address.as_server)(host, port) # noqa
 
     pid = ns.pop('pid')
     module = ns.pop('module')


Test patch:
diff --git a/tests/helpers/debugadapter.py b/tests/helpers/debugadapter.py
--- a/tests/helpers/debugadapter.py
+++ b/tests/helpers/debugadapter.py
@@ -235,20 +235,19 @@ def _start(cls, new_proc, argv, addr=None, **kwargs):
     def _ensure_addr(cls, argv, addr):
         if '--host' in argv:
             raise ValueError("unexpected '--host' in argv")
-        if '--server-host' in argv:
-            raise ValueError("unexpected '--server-host' in argv")
         if '--port' in argv:
             raise ValueError("unexpected '--port' in argv")
+        if '--client' in argv:
+            raise ValueError("unexpected '--client' in argv")
         host, port = addr
 
         argv.insert(0, str(port))
         argv.insert(0, '--port')
 
         argv.insert(0, host)
-        if addr.isserver:
-            argv.insert(0, '--server-host')
-        else:
-            argv.insert(0, '--host')
+        argv.insert(0, '--host')
+        if not addr.isserver:
+            argv.insert(0, '--client')
 
     def __init__(self, proc, addr, owned=False):
         super(DebugAdapter, self).__init__()
diff --git a/tests/ptvsd/test___main__.py b/tests/ptvsd/test___main__.py
--- a/tests/ptvsd/test___main__.py
+++ b/tests/ptvsd/test___main__.py
@@ -29,7 +29,7 @@ def test_module(self):
     def test_module_server(self):
         args, extra = parse_args([
             'eggs',
-            '--server-host', '10.0.1.1',
+            '--host', '10.0.1.1',
             '--port', '8888',
             '-m', 'spam',
         ])
@@ -48,6 +48,7 @@ def test_module_nodebug(self):
         args, extra = parse_args([
             'eggs',
             '--nodebug',
+            '--client',
             '--port', '8888',
             '-m', 'spam',
         ])
@@ -82,7 +83,7 @@ def test_script(self):
     def test_script_server(self):
         args, extra = parse_args([
             'eggs',
-            '--server-host', '10.0.1.1',
+            '--host', '10.0.1.1',
             '--port', '8888',
             'spam.py',
         ])
@@ -101,6 +102,7 @@ def test_script_nodebug(self):
         args, extra = parse_args([
             'eggs',
             '--nodebug',
+            '--client',
             '--port', '8888',
             'spam.py',
         ])
@@ -118,6 +120,7 @@ def test_script_nodebug(self):
     def test_remote(self):
         args, extra = parse_args([
             'eggs',
+            '--client',
             '--host', '1.2.3.4',
             '--port', '8888',
             'spam.py',
@@ -136,6 +139,7 @@ def test_remote(self):
     def test_remote_localhost(self):
         args, extra = parse_args([
             'eggs',
+            '--client',
             '--host', 'localhost',
             '--port', '8888',
             'spam.py',
@@ -155,6 +159,7 @@ def test_remote_nodebug(self):
         args, extra = parse_args([
             'eggs',
             '--nodebug',
+            '--client',
             '--host', '1.2.3.4',
             '--port', '8888',
             'spam.py',
@@ -192,7 +197,7 @@ def test_local_single_session(self):
         args, extra = parse_args([
             'eggs',
             '--single-session',
-            '--server-host', '1.2.3.4',
+            '--host', '1.2.3.4',
             '--port', '8888',
             'spam.py',
         ])
@@ -210,6 +215,7 @@ def test_local_single_session(self):
     def test_remote_wait(self):
         args, extra = parse_args([
             'eggs',
+            '--client',
             '--host', '1.2.3.4',
             '--port', '8888',
             '--wait',
@@ -267,6 +273,7 @@ def test_extra_nodebug(self):
             'eggs',
             '--DEBUG',
             '--nodebug',
+            '--client',
             '--port', '8888',
             '--vm_type', '???',
             'spam.py',
@@ -327,115 +334,6 @@ def test_unsupported_arg(self):
                     'spam.py',
                 ])
 
-    def test_backward_compatibility_host(self):
-        args, extra = parse_args([
-            'eggs',
-            '--client', '1.2.3.4',
-            '--port', '8888',
-            '-m', 'spam',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'module',
-            'name': 'spam',
-            'address': Address.as_client('1.2.3.4', 8888),
-            'nodebug': False,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
-    def test_backward_compatibility_host_nodebug(self):
-        args, extra = parse_args([
-            'eggs',
-            '--nodebug',
-            '--client', '1.2.3.4',
-            '--port', '8888',
-            '-m', 'spam',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'module',
-            'name': 'spam',
-            'address': Address.as_client('1.2.3.4', 8888),
-            'nodebug': True,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
-    def test_backward_compatibility_module(self):
-        args, extra = parse_args([
-            'eggs',
-            '--port', '8888',
-            '--module',
-            '--file', 'spam:',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'module',
-            'name': 'spam',
-            'address': Address.as_server(None, 8888),
-            'nodebug': False,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
-    def test_backward_compatibility_module_nodebug(self):
-        args, extra = parse_args([
-            'eggs',
-            '--nodebug',
-            '--port', '8888',
-            '--module',
-            '--file', 'spam:',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'module',
-            'name': 'spam',
-            'address': Address.as_client(None, 8888),
-            'nodebug': True,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
-    def test_backward_compatibility_script(self):
-        args, extra = parse_args([
-            'eggs',
-            '--port', '8888',
-            '--file', 'spam.py',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'script',
-            'name': 'spam.py',
-            'address': Address.as_server(None, 8888),
-            'nodebug': False,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
-    def test_backward_compatibility_script_nodebug(self):
-        args, extra = parse_args([
-            'eggs',
-            '--nodebug',
-            '--port', '8888',
-            '--file', 'spam.py',
-        ])
-
-        self.assertEqual(vars(args), {
-            'kind': 'script',
-            'name': 'spam.py',
-            'address': Address.as_client(None, 8888),
-            'nodebug': True,
-            'single_session': False,
-            'wait': False,
-        })
-        self.assertEqual(extra, self.EXPECTED_EXTRA)
-
     def test_pseudo_backward_compatibility(self):
         args, extra = parse_args([
             'eggs',
@@ -458,6 +356,7 @@ def test_pseudo_backward_compatibility_nodebug(self):
         args, extra = parse_args([
             'eggs',
             '--nodebug',
+            '--client',
             '--port', '8888',
             '--module',
             '--file', 'spam',