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)
| 305 | |
| 306 | |
| 307 | def 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 | |
| 340 | def main() -> None: |
no test coverage detected
searching dependent graphs…