diff --git a/ptvsd/__main__.py b/ptvsd/__main__.py index 6a07b6f73..fec1893a2 100644 --- a/ptvsd/__main__.py +++ b/ptvsd/__main__.py @@ -40,14 +40,28 @@ '--save-threading', '--save-asyncio', '--server', + '--qt-support=auto', } USAGE = """ - {0} [-h] [--nodebug] [--host HOST | --server-host HOST] --port PORT -m MODULE [arg ...] - {0} [-h] [--nodebug] [--host HOST | --server-host HOST] --port PORT FILENAME [arg ...] + {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 ...] """ # noqa +PYDEVD_DEFAULTS = { + '--qt-support=auto', +} + + +def _set_pydevd_defaults(pydevd_args): + args_to_append = [] + for arg in PYDEVD_DEFAULTS: + if arg not in pydevd_args: + args_to_append.append(arg) + return pydevd_args + args_to_append + + def parse_args(argv=None): """Return the parsed args to use in main().""" if argv is None: @@ -61,7 +75,8 @@ def parse_args(argv=None): supported, pydevd, script = _group_args(argv) args = _parse_args(prog, supported) - extra = pydevd + pydevd = _set_pydevd_defaults(pydevd) + extra = pydevd + ['--'] if script: extra += script return args, extra @@ -164,6 +179,8 @@ def _parse_args(prog, argv): target.add_argument('filename', nargs='?') parser.add_argument('--single-session', action='store_true') + parser.add_argument('-V', '--version', action='version') + parser.version = __version__ args = parser.parse_args(argv) ns = vars(args) diff --git a/tests/ptvsd/test___main__.py b/tests/ptvsd/test___main__.py index ea40dca83..53dd114bc 100644 --- a/tests/ptvsd/test___main__.py +++ b/tests/ptvsd/test___main__.py @@ -7,6 +7,8 @@ class ParseArgsTests(unittest.TestCase): + EXPECTED_EXTRA = ['--qt-support=auto', '--'] + def test_module(self): args, extra = parse_args([ 'eggs', @@ -21,7 +23,7 @@ def test_module(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_module_server(self): args, extra = parse_args([ @@ -38,7 +40,7 @@ def test_module_server(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_module_nodebug(self): args, extra = parse_args([ @@ -55,7 +57,7 @@ def test_module_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_script(self): args, extra = parse_args([ @@ -71,7 +73,7 @@ def test_script(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_script_server(self): args, extra = parse_args([ @@ -88,7 +90,7 @@ def test_script_server(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_script_nodebug(self): args, extra = parse_args([ @@ -105,7 +107,7 @@ def test_script_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_remote(self): args, extra = parse_args([ @@ -122,7 +124,7 @@ def test_remote(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_remote_localhost(self): args, extra = parse_args([ @@ -139,7 +141,7 @@ def test_remote_localhost(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_remote_nodebug(self): args, extra = parse_args([ @@ -157,7 +159,7 @@ def test_remote_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_remote_single_session(self): args, extra = parse_args([ @@ -174,7 +176,7 @@ def test_remote_single_session(self): 'nodebug': False, 'single_session': True, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_local_single_session(self): args, extra = parse_args([ @@ -192,7 +194,7 @@ def test_local_single_session(self): 'nodebug': False, 'single_session': True, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_extra(self): args, extra = parse_args([ @@ -220,6 +222,7 @@ def test_extra(self): self.assertEqual(extra, [ '--DEBUG', '--vm_type', '???', + '--qt-support=auto', '--', # Expected pydevd defaults '--xyz', '123', 'abc', '--cmd-line', @@ -255,6 +258,7 @@ def test_extra_nodebug(self): self.assertEqual(extra, [ '--DEBUG', '--vm_type', '???', + '--qt-support=auto', '--', # Expected pydevd defaults '--xyz', '123', 'abc', '--cmd-line', @@ -278,7 +282,7 @@ def test_empty_host(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_unsupported_arg(self): with self.assertRaises(SystemExit): @@ -305,7 +309,7 @@ def test_backward_compatibility_host(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_backward_compatibility_host_nodebug(self): args, extra = parse_args([ @@ -323,7 +327,7 @@ def test_backward_compatibility_host_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_backward_compatibility_module(self): args, extra = parse_args([ @@ -340,7 +344,7 @@ def test_backward_compatibility_module(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_backward_compatibility_module_nodebug(self): args, extra = parse_args([ @@ -358,7 +362,7 @@ def test_backward_compatibility_module_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_backward_compatibility_script(self): args, extra = parse_args([ @@ -374,7 +378,7 @@ def test_backward_compatibility_script(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_backward_compatibility_script_nodebug(self): args, extra = parse_args([ @@ -391,7 +395,7 @@ def test_backward_compatibility_script_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, []) + self.assertEqual(extra, self.EXPECTED_EXTRA) def test_pseudo_backward_compatibility(self): args, extra = parse_args([ @@ -408,7 +412,7 @@ def test_pseudo_backward_compatibility(self): 'nodebug': False, 'single_session': False, }) - self.assertEqual(extra, ['--module']) + self.assertEqual(extra, ['--module'] + self.EXPECTED_EXTRA) def test_pseudo_backward_compatibility_nodebug(self): args, extra = parse_args([ @@ -426,4 +430,4 @@ def test_pseudo_backward_compatibility_nodebug(self): 'nodebug': True, 'single_session': False, }) - self.assertEqual(extra, ['--module']) + self.assertEqual(extra, ['--module'] + self.EXPECTED_EXTRA)