MCPcopy Index your code
hub / github.com/github/copilot-sdk / get_or_download_cli

Function get_or_download_cli

python/copilot/_cli_download.py:307–337  ·  view source on GitHub ↗

Get the cached CLI binary, downloading it if necessary. Returns None if: - No version is pinned (dev install) - Auto-download is disabled via COPILOT_SKIP_CLI_DOWNLOAD - The platform is unsupported Raises RuntimeError on download/verification failures.

(version: str | None = None)

Source from the content-addressed store, hash-verified

305
306
307def get_or_download_cli(version: str | None = None) -> str | None:
308 """Get the cached CLI binary, downloading it if necessary.
309
310 Returns None if:
311 - No version is pinned (dev install)
312 - Auto-download is disabled via COPILOT_SKIP_CLI_DOWNLOAD
313 - The platform is unsupported
314
315 Raises RuntimeError on download/verification failures.
316 """
317 ver = version or CLI_VERSION
318 if not ver:
319 return None
320
321 # Check cache first
322 cached = get_cached_cli_path(ver)
323 if cached:
324 return cached
325
326 # Check if download is disabled
327 if _should_skip_download():
328 return None
329
330 # Check platform support before attempting download
331 try:
332 get_asset_info()
333 except RuntimeError:
334 return None
335
336 # Download
337 return download_cli(ver)
338
339
340def main() -> None:

Callers 1

_get_or_download_cliFunction · 0.85

Calls 4

get_cached_cli_pathFunction · 0.85
_should_skip_downloadFunction · 0.85
get_asset_infoFunction · 0.85
download_cliFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…