MCPcopy Create free account
hub / github.com/python-websockets/websockets / main

Function main

src/websockets/cli.py:145–178  ·  view source on GitHub ↗
(argv: list[str] | None = None)

Source from the content-addressed store, hash-verified

143
144
145def main(argv: list[str] | None = None) -> None:
146 parser = argparse.ArgumentParser(
147 prog="websockets",
148 description="Interactive WebSocket client.",
149 add_help=False,
150 )
151 group = parser.add_mutually_exclusive_group()
152 group.add_argument("--version", action="store_true")
153 group.add_argument("uri", metavar="<uri>", nargs="?")
154 args = parser.parse_args(argv)
155
156 if args.version:
157 print(f"websockets {websockets_version}")
158 return
159
160 if args.uri is None:
161 parser.print_usage()
162 sys.exit(2)
163
164 # Enable VT100 to support ANSI escape codes in Command Prompt on Windows.
165 # See https://github.com/python/cpython/issues/74261 for why this works.
166 if sys.platform == "win32":
167 os.system("")
168
169 try:
170 import readline # noqa: F401
171 except ImportError: # readline isn't available on all platforms
172 pass
173
174 # Remove the try/except block when dropping Python < 3.11.
175 try:
176 asyncio.run(interactive_client(args.uri))
177 except KeyboardInterrupt: # pragma: no cover
178 pass

Callers 1

__main__.pyFile · 0.70

Calls 1

interactive_clientFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…