MCPcopy Create free account
hub / github.com/microsoft/debugpy / cli_parser

Function cli_parser

tests/debugpy/server/test_cli.py:21–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19def cli(pyfile):
20 @pyfile
21 def cli_parser():
22 import os
23 import pickle
24 import sys
25 from debugpy.server import cli
26
27 try:
28 cli.parse_args()
29 except Exception as exc:
30 os.write(1, pickle.dumps(exc))
31 sys.exit(1)
32
33 # Check that sys.argv has the correct type after parsing - there should be no bytes.
34 assert all(isinstance(s, str) for s in sys.argv)
35
36 # We only care about options that correspond to public switches.
37 options = {
38 name: getattr(cli.options, name)
39 for name in [
40 "address",
41 "config",
42 "log_to",
43 "log_to_stderr",
44 "mode",
45 "target",
46 "target_kind",
47 "wait_for_client",
48 "parent_session_pid",
49 ]
50 }
51
52 # Serialize the command line args and the options to stdout
53 serialized_data = pickle.dumps([sys.argv[1:], options])
54 os.write(1, serialized_data)
55 # Ensure all data is written before process exits
56 sys.stdout.flush()
57
58 def parse(args):
59 log.debug("Parsing argv: {0!r}", args)

Callers

nothing calls this directly

Calls 4

allFunction · 0.85
dumpsMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…