Locate Hub CLI with fallback strategy. Search order: 1. UNITY_HUB_PATH environment variable 2. PATH lookup (shutil.which) 3. Platform-specific known locations
()
| 74 | |
| 75 | @lru_cache(maxsize=1) |
| 76 | def locate_hub_cli() -> Path | None: |
| 77 | """Locate Hub CLI with fallback strategy. |
| 78 | |
| 79 | Search order: |
| 80 | 1. UNITY_HUB_PATH environment variable |
| 81 | 2. PATH lookup (shutil.which) |
| 82 | 3. Platform-specific known locations |
| 83 | """ |
| 84 | # 1. Environment variable override |
| 85 | if env_path := os.environ.get("UNITY_HUB_PATH"): |
| 86 | path = Path(env_path) |
| 87 | if path.exists(): |
| 88 | return path |
| 89 | |
| 90 | # 2. PATH lookup |
| 91 | which_names = ["unityhub", "Unity Hub"] |
| 92 | for name in which_names: |
| 93 | if which_path := shutil.which(name): |
| 94 | return Path(which_path) |
| 95 | |
| 96 | # 3. Platform-specific known locations |
| 97 | for candidate in _get_platform_hub_candidates(): |
| 98 | if candidate.exists(): |
| 99 | return candidate |
| 100 | |
| 101 | return None |
| 102 | |
| 103 | |
| 104 | @lru_cache(maxsize=1) |
no test coverage detected